如何使用 cython 编译扩展? [英] How can I compile an extension using cython?

查看:40
本文介绍了如何使用 cython 编译扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从示例页面这里 在我安装了 Python 2.6 64 位版本的 Windows 7 64 位机器上.我从 Gohlke 的页面.

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.

基本上,来自此处这里 不是我的选择,因为我确实需要 Python 64 位版本来处理更大的内存.另外,因为我正在尝试使用 Microsoft SDK for .NET 4<进行编译/a>,我不能在后一种解决方案中使用这种方法.

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.

我尝试了 此处 的步骤并观察到绿色窗口,但编译现在抛出 cannot找到 vcvarsall.bat 错误.以下是我尝试的命令序列:

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 FilesMicrosoft SDKsWindowsv7.1"
C:Program FilesMicrosoft SDKsWindowsv7.1>set DISTUTILS_USE_SDK=1
C:Program FilesMicrosoft SDKsWindowsv7.1>setenv /x64 /release

Setting SDK environment relative to C:Program FilesMicrosoft SDKsWindowsv7.1.
Targeting Windows 7 x64 Release

C:Program FilesMicrosoft SDKsWindowsv7.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?

推荐答案

这是我的一个批处理文件的摘录:

Here is an excerpt from one of my batch files:

rem Configure the environment for 64-bit builds.
rem Use "vcvars32.bat" for a 32-bit build.
"C:Program Files (x86)Microsoft Visual Studio 9.0VCinvcvars64.bat"
rem Convince setup.py to use the SDK tools.
set MSSdk=1
set DISTUTILS_USE_SDK=1 

7.1 SDK 使用了有效的 VS2010,但 Python 2.6 是使用 VS2008 编译的.如果您可以使用 7.0 SDK(我认为它也称为 .NET 3.5 SDK),您将可以访问 VS2008 的编译器.混合不同的编译器和运行时库是有风险的.

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.

这篇关于如何使用 cython 编译扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆