gpt4 book ai didi

python - Cython 无法在 Windows 7 x64 上编译

转载 作者:太空狗 更新时间:2023-10-29 21:35:28 26 4
gpt4 key购买 nike

我正在努力在 Windows 7 x64 上安装 Cython。我下载并安装了 Automated MinGW 安装程序。为 distutils 文件夹创建了一个 distutils.cfg,内容如下:

[build]
compiler = mingw32

C:\MinGW\bin 添加到环境变量后,我调用了 easy_install Cython 但出现以下错误。强奸互联网并没有给我带来有用的结果,因为所有这些编译的东西(或者我应该说 sh*t ?) 对我来说太新了。

c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5d59): undefined reference to `_imp__PyObject_GetAttr'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5dc5): undefined reference to `_imp__PyObject_GetAttr'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5e31): undefined reference to `_imp__PyObject_GetAttr'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5ebc): undefined reference to `_imp__PyObject_Call'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5f08): undefined reference to `_imp__PyDict_New'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5f49): undefined reference to `_imp__PyObject_SetAttr'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x5ffe): undefined reference to `_imp__PyErr_Occurred'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x6013): undefined reference to `_imp__PyExc_ImportError'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x601e): undefined reference to `_imp__PyErr_SetString'
c:\users\niklas\appdata\local\temp\easy_install-dgjjub\cython-0.15\cython\plex\scanners.o:Scanners.c:(.text+0x602d): undefined reference to `_imp__PyInt_FromLong'
collect2: ld returned 1 exit status
dllwrap: gcc exited with status 1
error: Setup script exited with error: command 'dllwrap' failed with exit status 1

任何想法出了什么问题?谢谢!

更新:我使用 dlltools 创建了 libpython27.a,然后再次尝试构建 Cython,它运行良好!但是现在,调用 cython.exe 会出现此错误:

ImportError: DLL load failed, %1 is not a valid Win32-executable.

我假设这是因为我使用 Pythonx64 而不是 MinGW32 编译器?那么,我如何为 x64 编译它?

最佳答案

有预编译的Cython包on this site .我建议您切换到 x86 Python,使用 x64 版本并没有真正的优势。如果您想坚持使用 x64,则不能使用 MingW,而必须使用 MS SDK C++ 编译器 (more on this)。

Do not use MinGW-w64. As you will notice, the MinGW import library for Python (e.g. libpython27.a) is omitted from the AMD64 version of Python. This is deliberate. Do not try to make one using dlltool. [...] There have also been issues with the mingw runtime conflicting with the MSVC runtime; this can happen from places you don't expect, such as inside runtime libraries for g++ or gfortran.

关于python - Cython 无法在 Windows 7 x64 上编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6982009/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com