当我尝试在 Windows 7 下使用 Python 3.3 (Anaconda 3) 构建最小的 Cython 文件 test.pyx 时,我收到一个奇怪的错误:
C:\Users\myname\Test_cython>python setup.py build
running build
running build_ext
error: [WinError 2] The system cannot find the file specified
当然 test.pyx 在工作目录中。它在 Windows 下使用 Python 2.7 (Anaconda) 以及在 Linux 下使用 Python 2 和 3 运行良好。
Python 3.3 (Anaconda 3) 可能存在什么问题?
Thanks
文件setup.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(
name = 'test',
cmdclass = {"build_ext": build_ext},
ext_modules = [Extension('test', ['test.pyx'])]
)
解决方案:
我发现disutils包的cygwinccompiler.py文件的第404行
out_string = check_output(['gcc', '-dumpmachine'])
必须更改为
out_string = check_output(['gcc', '-dumpmachine'], shell=True)
然后就可以正常编译了。