我正在尝试使用cython将c ++代码包装到python中。我的.py代码是
from distutils.core import setup
from Cython.Build import cythonize
setup(
ext_modules=cythonize("helloworld.pyx"),
)
但是在用
进行编译时python setup.py build_ext --inplace
我收到错误
running build_ext
building 'helloworld' extension
Traceback (most recent call last):
File "setup.py", line 4, in <module>
ext_modules=cythonize("helloworld.pyx"),
File "C:\Python34\lib\distutils\core.py", line 148, in setup
dist.run_commands()
File "C:\Python34\lib\distutils\dist.py", line 955, in run_commands
self.run_command(cmd)
File "C:\Python34\lib\distutils\dist.py", line 974, in run_command
cmd_obj.run()
File "C:\Python34\lib\distutils\command\build_ext.py", line 339, in run
self.build_extensions()
File "C:\Python34\lib\distutils\command\build_ext.py", line 448, in build_extensions
self.build_extension(ext)
File "C:\Python34\lib\distutils\command\build_ext.py", line 503, in build_extension
depends=ext.depends)
File "C:\Python34\lib\distutils\msvc9compiler.py", line 460, in compile
self.initialize()
File "C:\Python34\lib\distutils\msvc9compiler.py", line 371, in initialize
vc_env = query_vcvarsall(VERSION, plat_spec)
File "C:\Python34\lib\distutils\msvc9compiler.py", line 287, in query_vcvarsall
raise ValueError(str(list(result.keys())))
ValueError: ['path']
我正在开发visual studio 2010.我有点意识到这个错误是因为vcvars6.bat但我不知道如何解决它。请帮助
答案 0 :(得分:2)
看起来你正在运行64位。 Visual Studio 2010是only the right choice if you are using Python 3.3 or 3.4。
我猜你没有正确设置编译器。在Python 3.4部分Ionel's Codelog中讨论了正确的安装顺序(VC ++ 2010,Windows SDK for VS 2010,.NET 4.0,创建虚假的vcvars64.bat文件,应用VC 2010 SP1,应用VC ++ 2010 SP1。
或者,您也可以尝试设置一些环境变量,如Ionel的Codelog帖子中Python 3.4部分底部所述。
我猜测你的版本错误,订单错误,或者跳过假的.bat文件或环境变量。