Как использовать Cython на Windows 10 с python 3,8 - PullRequest
0 голосов
/ 20 февраля 2020

Я хочу знать, как правильно конвертировать документы py в C с помощью Cython, но все время возникают ошибки.

D:\Cython\test4>python setup.py build_ext --inplace
running build_ext
Traceback (most recent call last):
  File "setup.py", line 4, in <module>
    setup(ext_modules = cythonize('hello.pyx', compiler_directives={'language_level': 3}))
  File "C:\Users\Alexandr\AppData\Local\Programs\Python\Python38\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\Alexandr\AppData\Local\Programs\Python\Python38\lib\distutils\dist.py", line 966, in run_commands
    self.run_command(cmd)
  File "C:\Users\Alexandr\AppData\Local\Programs\Python\Python38\lib\distutils\dist.py", line 985, in run_command
    cmd_obj.run()
  File "C:\Users\Alexandr\AppData\Local\Programs\Python\Python38\lib\distutils\command\build_ext.py", line 306, in run
    self.compiler = new_compiler(compiler=self.compiler,
  File "C:\Users\Alexandr\AppData\Local\Programs\Python\Python38\lib\distutils\ccompiler.py", line 1032, in new_compiler
    return klass(None, dry_run, force)
  File "C:\Users\Alexandr\AppData\Local\Programs\Python\Python38\lib\distutils\cygwinccompiler.py", line 282, in __init__
    CygwinCCompiler.__init__ (self, verbose, dry_run, force)
  File "C:\Users\Alexandr\AppData\Local\Programs\Python\Python38\lib\distutils\cygwinccompiler.py", line 157, in __init__
    self.dll_libraries = get_msvcr()
  File "C:\Users\Alexandr\AppData\Local\Programs\Python\Python38\lib\distutils\cygwinccompiler.py", line 86, in get_msvcr
    raise ValueError("Unknown MS Compiler version %s " % msc_ver)
ValueError: Unknown MS Compiler version 1916

У меня есть файл hello.pyx, который включает этот код

cpdef int test(int x):
    cdef int y = 1
    cdef int i
    for i in range(1, x+1):
        y *= i
    return y

Файл setup.py содержит

   from distutils.core import setup 
   from Cython.Build import cythonize
   setup(ext_modules = cythonize('hello.pyx', compiler_directives={'language_level': 3}))

Установлена ​​Microsoft Visual Studio, также установлен компилятор g cc. Что мне делать?

...