Cython不会在Windows 7 x64上编译

2024-04-29 14:45:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我正努力在Windows7x64上安装Cython。 我下载并安装了automated MinGW installer。创建了distutils.cfg到distutils文件夹,其中包含以下内容:

[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呢?


Tags: installtextlocaleasyplexusersappdatatemp
1条回答
网友
1楼 · 发布于 2024-04-29 14:45:55

有预编译的Cython包on this site。我建议您切换到x86 Python,使用x64版本不会获得真正的优势。如果你想坚持X64,你不能使用MingW,你必须使用MSDK 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.

相关问题 更多 >