gpt4 book ai didi

python-3.x - 在 Windows 7 下使用 python 3.3 (Anaconda) 构建最小的 cython 文件

转载 作者:行者123 更新时间:2023-12-03 11:19:59 34 4
gpt4 key购买 nike

当我尝试在 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 在工作目录中。它在使用 Python 2.7 (Anaconda) 的 Windows 下以及使用 Python 2 和 3 的 Linux 下都可以正常工作。

Python 3.3(Anaconda 3)可能有什么问题?

谢谢

文件 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)

然后,它正常编译。

最佳答案

disutils包的cygwinccompiler.py文件第404行

out_string = check_output(['gcc', '-dumpmachine'])

必须更改为
out_string = check_output(['gcc', '-dumpmachine'], shell=True)

然后,它正常编译。

关于python-3.x - 在 Windows 7 下使用 python 3.3 (Anaconda) 构建最小的 cython 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24291506/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com