Cython将无法在Windows 7 x64上编译

时间:2011-08-08 12:20:28

标签: python windows-7 mingw 64-bit cython

我正在努力在Windows 7 x64上安装Cython。 我下载并安装了automated MinGW installer。使用以下内容为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编译它?

1 个答案:

答案 0 :(得分:10)

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

  

请勿使用MinGW-w64 。正如您将注意到的,MinGW导入库   从AMD64版本中省略了Python(例如libpython27.a)   蟒蛇。这是故意的。   不要尝试使用dlltool制作一个。   [...] mingw运行时也存在问题   与MSVC运行时冲突;这可能发生在你的地方   不要指望,例如g ++或gfortran的运行时库内部。

相关问题