在 windows 7 下使用 python 3.3 (Anaconda) 构建最小的 cython 文件 [英] Building minimal cython file with python 3.3 (Anaconda) under windows 7
问题描述
当我尝试在 windows 7 下使用 Python 3.3 (Anaconda 3) 构建最小的 Cython 文件 test.pyx 时,我收到一个奇怪的错误:
When I try to build a minimal Cython file test.pyx with Python 3.3 (Anaconda 3) under windows 7, I obtain a strange error:
C:UsersmynameTest_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 运行良好.
Of course test.pyx is in the working directory. It works fine under windows with Python 2.7 (Anaconda) and under Linux with Python 2 and 3.
Python 3.3 (Anaconda 3) 可能存在什么问题?
What could be the problem here with Python 3.3 (Anaconda 3)?
谢谢
文件 setup.py:
The file 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行
I found that the line 404 of the file cygwinccompiler.py of the package disutils
out_string = check_output(['gcc', '-dumpmachine'])
必须改成
out_string = check_output(['gcc', '-dumpmachine'], shell=True)
然后,它就可以正常编译了.
Then, it compiles normally.
推荐答案
disutils包的cygwinccompiler.py文件第404行
The line 404 of the file cygwinccompiler.py of the package disutils
out_string = check_output(['gcc', '-dumpmachine'])
必须改成
out_string = check_output(['gcc', '-dumpmachine'], shell=True)
然后,它就可以正常编译了.
Then, it compiles normally.
这篇关于在 windows 7 下使用 python 3.3 (Anaconda) 构建最小的 cython 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!