2011-08-08 56 views
7

我很努力在Windows 7 x64上安裝Cython。我下載並安裝了。創建一個distutils.cfg給Distutils的文件夾包含以下內容:Cython無法在Windows 7 x64上編譯

[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 

任何想法什麼是錯的?謝謝 !

UPDATE: 我用dlltools創建libpython27.a,然後再次嘗試構建Cython,它只是工作正常! 但現在,調用cython.exe提供了這樣的錯誤:

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

我想這是因爲我使用Pythonx64但MINGW32編譯器? 那麼,我怎樣才能編譯它爲X64?

+0

@lance你改變了什麼? //標題。 –

+1

標題。您可以通過點擊上面我的頭像上方的「編輯」一詞後面直接出現的「X mins ago」文本來查看修訂修改摘要。 – lance

+1

太棒了,不知道xD謝謝 –

回答

10

有預編譯的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.

+1

+1,更改爲x86做到了。謝謝 ! –

相關問題