如何使用 cython 编译扩展?
我正在尝试从示例页面 此处 编译一个简单的 cython 扩展安装了 Python 2.6 64 位版本的 Windows 7 64 位计算机。我从 Gohlke 页面。
基本上,答案来自此处和这里不是我的选择,因为我确实需要Python 64位版本来解决更大的内存。另外,因为我尝试使用 Microsoft SDK for .NET 4< 进行编译/a>,我无法使用后一个解决方案中的方法。
我尝试了此处的步骤并观察到绿色窗口,但编译现在抛出无法找到vcvarsall。蝙蝠
错误。以下是我尝试过的命令序列:
C:\>cd "Program Files\Microsoft SDKs\Windows\v7.1\"
C:\Program Files\Microsoft SDKs\Windows\v7.1>set DISTUTILS_USE_SDK=1
C:\Program Files\Microsoft SDKs\Windows\v7.1>setenv /x64 /release
Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v7.1\.
Targeting Windows 7 x64 Release
C:\Program Files\Microsoft SDKs\Windows\v7.1>e:
E:\>cd cython
E:\cython>python setup.py build_ext --inplace
running build_ext
skipping 'fib.c' Cython extension (up-to-date)
building 'fib' extension
error: Unable to find vcvarsall.bat
关于如何解决这个问题有什么建议吗?
I am trying to compile a simple cython extension from the example page here on my Windows 7 64-bit machine with Python 2.6 64-bit version installed. I installed Cython 0.15.1 for Windows 64-bit version from Gohlke's page.
Basically, the answer from here and here are not my options because I really do need Python 64-bit version to address larger memory. Also, because I am trying to compile using Microsoft SDK for .NET 4, I cannot use the approach in the latter solution.
I tried the steps here and observed the green window but compilation now throws the cannot find vcvarsall.bat
error. Following is the sequence of commands I tried:
C:\>cd "Program Files\Microsoft SDKs\Windows\v7.1\"
C:\Program Files\Microsoft SDKs\Windows\v7.1>set DISTUTILS_USE_SDK=1
C:\Program Files\Microsoft SDKs\Windows\v7.1>setenv /x64 /release
Setting SDK environment relative to C:\Program Files\Microsoft SDKs\Windows\v7.1\.
Targeting Windows 7 x64 Release
C:\Program Files\Microsoft SDKs\Windows\v7.1>e:
E:\>cd cython
E:\cython>python setup.py build_ext --inplace
running build_ext
skipping 'fib.c' Cython extension (up-to-date)
building 'fib' extension
error: Unable to find vcvarsall.bat
Any suggestions on how I solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(3)
http://wiki.cython.org/64BitCythonExtensionsOnWindows 上的文档说:
对于 Python 2.6、2.7 和 3.1,您应该使用 Microsoft Windows SDK
适用于 Windows 7 和 .NET Framework 3.5 SP1。较新或较早版本
SDK 将链接到错误的 C 运行时。请注意,以后的版本
Python 可能需要更新版本的 Windows
SDK。这是确保扩展程序与
与 Python 相同的 C 运行时版本。使用正确版本的 SDK
是使用 Microsoft 构建工具控制此问题的唯一方法。
微软现在有专门针对Python 2.7的ac编译器包。
我建议你使用它来代替 SDK 和 VS。 VS Express 版本没有 64 位编译器,这就是理论上您需要 SDK 的原因。我尝试安装 SDK 但没有帮助。如果您不需要 SDK 或 VS 进行其他操作,请卸载它们并使用 http://www.microsoft.com/en-gb/download/details.aspx?id=44266。
如果安装编译器后仍然遇到问题,我对 pyusb 2.7 Windows 安装错误 可能会有所帮助。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
以下是我的批处理文件之一的摘录:
7.1 SDK 使用的实际上是 VS2010,但 Python 2.6 是使用 VS2008 编译的。如果您可以使用7.0 SDK(我认为它也称为.NET 3.5 SDK),您将可以访问VS2008的编译器。混合不同的编译器和运行时库是有风险的。
Here is an excerpt from one of my batch files:
The 7.1 SDK uses what is effectively VS2010 but Python 2.6 is compiled with VS2008. If you can use the 7.0 SDK (I think it is also known as the .NET 3.5 SDK), you will have access to VS2008's compiler. It is risky to mix different compilers and runtimes libraries.