How to build cython pyx to pyd in anaconda(python3.6) in windows 8.1?

感情迁移 提交于 2019-12-21 19:52:51

问题


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:


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.)



来源:https://stackoverflow.com/questions/47944304/how-to-build-cython-pyx-to-pyd-in-anacondapython3-6-in-windows-8-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!