How to build cython pyx to pyd in anaconda(python3

2020-07-22 08:59发布

I have referred some websites to build pyx to pyd in Windows 8.1.I 'm using Anaconda Distribution with Spyder IDE, I have developed pyx file and unable to build in "Anaconda Command Prompt" Anaconda>

python setup.py build --inplace --compiler=mingw32 

and tried

python setup.py build_ext --inplace --compiler=mingw32

getting following error:

File "C:\ProgramData\Anaconda3\lib\distutils\cygwinccompiler.py", line 129 in __init__  
  if self.ld_version >= "2.10.90":
TypeError: '>=' not supported between instances of 'NoneType' and 'str'

my simple pyx code is

cdef int fib(int n):    
    cdef int a, b, i
    a, b  = 1, 1
    for i in range(n):
       a, b = a+b, a
    return a

and my setup.py file as below..

from distutils.core import setup
from Cython.Build import cythonize

setup(ext_modules = cythonize('fb.pyx'))

Howto get rid of this in windows 8.1? I would like use Struct and Socket libraries for my socket programming.

1条回答
戒情不戒烟
2楼-- · 2020-07-22 09:39

There's nothing wrong with your .pyx or setup.py code AFAICT. I am using Anaconda3 on windows 10 and it works.

The issue is with the compiler. Did you install mingw32 yourself? It looks like whichever version you have cannot compile the code. I got the same error for cygwin

But, the code compiled fine for me using the compiler included in Visual Studio 14 and the borlands compiler.

Try --compiler=bcpp (hopefully already be on your system)

or

Try installing: http://landinghub.visualstudio.com/visual-cpp-build-tools and run your compile command with --compiler=msvc (or just without specifying the compiler.)

查看更多
登录 后发表回答