python-3.x - 如何在 Windows 8.1 的 anaconda(python3.6) 中构建 cython pyx 到 pyd?

标签 python-3.x sockets struct cython cythonize

我已经引用了一些网站来在 Windows 8.1 中构建 pyx 到 pyd。我正在使用带有 Spyder IDE 的 Anaconda Distribution,我已经开发了 pyx 文件并且无法在“Anaconda 命令提示符”中构建
python >

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

并尝试
python setup.py build_ext --inplace --compiler=mingw32

收到以下错误:
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'

我的简单 pyx 代码是
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

和我的 setup.py 文件如下..
from distutils.core import setup
from Cython.Build import cythonize

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

如何在 Windows 8.1 中摆脱这个?我想在我的套接字编程中使用 Struct 和 Socket 库。

最佳答案

您的 .pyx 或 setup.py 代码 AFAICT 没有任何问题。
我在 Windows 10 上使用 Anaconda3,它可以工作。

问题出在编译器上。你自己安装了mingw32吗?
看起来您拥有的任何版本都无法编译代码。
我对 cygwin 也有同样的错误

但是,使用 Visual Studio 14 和 borlands 编译器中包含的编译器对我来说,代码编译得很好。

尝试 --compiler=bcpp (希望已经在你的系统上)

或者

尝试安装:http://landinghub.visualstudio.com/visual-cpp-build-tools
并使用 --compiler=msvc 运行你的编译命令(或者不指定编译器。)

关于python-3.x - 如何在 Windows 8.1 的 anaconda(python3.6) 中构建 cython pyx 到 pyd?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47944304/

相关文章:

javascript - JS SocketIO 单例

c - 如何在C函数中访问这个结构体数组?

python - 带有一行数据的 Pandas read_csv() 返回 Empty Dataframe

python - 排除基于另一个没有外键的模型的值的模型

python - 正确使用ctypes来调用_Py_Mangle?

javascript - 回调函数socket.io + node.js

node.js - Firefox 插件中的 Socket.io

python - 使用 SWIG 将 C 结构数组访问到 Python

C 结构 : Problem Initializing? Valgrind 错误

python - AttributeError : 'list' object has no attribute 'isdigit' . 有效指定句子列表中每个单词的 POS?