2010-12-15 124 views
19

試圖在運行Ubuntu服務器的小型VPS上安裝Cython。難道Cython安裝GCC錯誤

sudo apt-get install gcc 

然後

python setup.py install 

在用Cython目錄,但我得到這個奇怪的錯誤。

running install 
running build 
running build_py 
running build_ext 
building 'Cython.Plex.Scanners' extension 
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.6 -c Cython/Plex/Scanners.c -o build/temp.linux-x86_64-2.6/Cython/Plex/Scanners.o 
Cython/Plex/Scanners.c:4:20: error: Python.h: No such file or directory 
Cython/Plex/Scanners.c:6:6: error: #error Python headers needed to compile C extensions, please install development version of Python. 
error: command 'gcc' failed with exit status 1 

爲什麼我需要'開發版本的Python'?運行Python 2.6.5(r265:79063,2010年4月16日,13:57:41)。謝謝!

回答

36

你需要的Python的開發者版本 - 即Python的頭文件(Python.h)

sudo apt-get install python-dev 
+0

好吧!請問爲什麼這是必要的?我的開發機器(Windows)只有標準的Python 2.6並且工作正常。然後,我再次通過打包安裝程序進行安裝,因此它可能包含了所有內容。 – DizzyDoo 2010-12-15 13:20:34

+0

一個簡單的答案就是Cython中的一些源文件#包括一些python頭文件,所以你需要python頭文件來編譯Cython。如果您想知道爲什麼使用這些文件,那麼您需要查看Cython源代碼。 – binW 2010-12-15 13:30:37

+1

這也是由於Ubuntu和Debian選擇分離開發包的事實。 – user225312 2010-12-15 14:39:16

4

你需要包含在Python的開發版本的標題,即python.h。它應該在Ubuntu中打包爲python-dev