【问题标题】:Python 3.4: compile cython module for 64-bit windowsPython 3.4:为 64 位 Windows 编译 cython 模块
【发布时间】:2015-02-13 19:00:39
【问题描述】:

我有一个 .pyx 模块,我一直在尝试通过各种方式编译它以在 Windows 上与 64 位 python 3.4 一起使用,但没有成功。

经过大量的试验和错误,它确实可以编译

python setup.py build_ext --inplace --compiler=mingw32

当然,这不适用于 64 位 python。

以msvc为编译器,报错

File "C:\Python34\lib\distutils\msvc9compiler.py", line 287, in query_vcvarsall
raise ValueError(str(list(result.keys())))
ValueError: ['path']
  • Windows 7
  • 已安装适用于 Windows 7 和 .NET Framework 4 的 Microsoft Windows SDK
  • C:\Program Files (x86) 中似乎有一些 Microsoft Visual Studio 10.0 内容(包括 vcvarsall.bat)

也欢迎不围绕 distutils 的解决方案。

--- 编辑:附加信息

我现在修改了 distutils 以根据 http://bugs.python.org/issue11723 识别 mingw-w64。然后我使用 gendef 和 dlltool 制作了 libpython34.a,但出现错误

c:\Python34\libs/libpython34.a: file not recongnized: File truncated

运行时

python setup.py build_ext --inplace --compiler=mingw64

【问题讨论】:

  • 为什么不安装 64 位 mingw 工具链?
  • 有什么特别推荐的吗?据我所见,有一些......我安装了 mingw-w64,但 distutils 没有提供它作为选项,所以我想还有更多?

标签: windows python-3.x cython distutils mingw-w64


【解决方案1】:

好的,我终于成功了。

Christoph Gohlke (http://www.lfd.uci.edu/~gohlke/pythonlibs) 的精彩资源是关键。

  1. 以常规方式安装所需的 Python 版本
  2. 从 Gohlke 的网站安装您需要的任何扩展程序
  3. http://tdm-gcc.tdragon.net/download 安装 MinGW-w64
  4. 根据http://bugs.python.org/issue11723 修补 distutils
  5. 从 Gohlke 的站点安装适当版本的 libpython
  6. 鲍勃的叔叔

(为此任务尝试了各种疯狂的建议,我经历了更多的步骤,但据我所知,最终真正有所作为的只有这些)

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2012-06-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-11-11
  • 2016-04-02
  • 2011-03-25
  • 2017-02-08
相关资源
最近更新 更多