windows - python 3.4 : compile cython module for 64-bit windows

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

我有一个 .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 的解决方案。

--- 编辑:附加信息

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

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

运行时

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

最佳答案

好吧,我终于成功了。

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. 鲍勃的你叔叔

(为此任务尝试了各种疯狂的建议,我经历了更多的步骤,但据我所知,这些是最终真正产生影响的唯一步骤)

关于windows - python 3.4 : compile cython module for 64-bit windows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27488163/

相关文章:

python - 在 Mac 上将使用 Cython 编译的 c 模块导入到 python 模块时出错

python - WSL Ubuntu - 制作 libfreenect - CYTHON_EXECUTABLE-NOTFOUND

json - 在 elasticsearch 中删除超过 30 天的文档

python-3.x - 如何从 Pandas 字符串中提取前8个字符

python - 将值转换为整数,同时过滤包含特殊字符的字符串

python - 过滤列值并收到 future 警告和类型错误?

python - Cython,关于 vector (大小)构造函数的混淆

java - Thingsboard Windows 安装错误

windows - 如何从 PreTranslateMessage(MSG*pMsg) 中的 WM_KEYDOWN 中提取字符

sql-server - "> sql.txt && sql -h-1 -i sql.txt && del sql.txt"命令是什么意思?