2013-06-13 93 views
2

我是python3的新手。我創建了虛擬環境。我嘗試使用pip命令安裝pycairo軟件包。我需要安裝python cairo。請參閱下面的信息如何安裝python開羅?

pip install git+http://anongit.freedesktop.org/git/pycairo 
Downloading/unpacking git+http://anongit.freedesktop.org/git/pycairo 
    Cloning http://anongit.freedesktop.org/git/pycairo to /tmp/pip-0c_foz-build 
    Running setup.py egg_info for package from git+http://anongit.freedesktop.org/git/pycairo 
    cairo >= 1.10.2 Successful 

Installing collected packages: pycairo 
    Running setup.py install for pycairo 
    cairo >= 1.10.2 Successful 
    building 'cairo._cairo' extension 
    gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/python3.2mu -c src/cairomodule.c -o build/temp.linux-i686-3.2/src/cairomodule.o 
    src/cairomodule.c:22:20: fatal error: Python.h: No such file or directory 
    compilation terminated. 
    error: command 'gcc' failed with exit status 1 
    Complete output from command /home/nyros/Desktop/NewWeb/venv/bin/python3 -c "import setuptools;__file__='/tmp/pip-0c_foz-build/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lo0egc-record/install-record.txt --single-version-externally-managed --install-headers /home/nyros/Desktop/NewWeb/venv/include/site/python3.2: 
    cairo >= 1.10.2 Successful 

creating py3cairo.pc 

creating src/config.h 

running install 

running build 

running build_ext 

building 'cairo._cairo' extension 

creating build 

creating build/temp.linux-i686-3.2 

creating build/temp.linux-i686-3.2/src 

gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/python3.2mu -c src/cairomodule.c -o build/temp.linux-i686-3.2/src/cairomodule.o 

src/cairomodule.c:22:20: fatal error: Python.h: No such file or directory 

compilation terminated. 

error: command 'gcc' failed with exit status 1 

---------------------------------------- 
Command /home/nyros/Desktop/NewWeb/venv/bin/python3 -c "import setuptools;__file__='/tmp/pip-0c_foz-build/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lo0egc-record/install-record.txt --single-version-externally-managed --install-headers /home/nyros/Desktop/NewWeb/venv/include/site/python3.2 failed with error code 1 in /tmp/pip-0c_foz-build 
Storing complete log in /home/nyros/.pip/pip.log 

但我得到了錯誤。請解決我的問題。由於

+0

你可以發佈命令的結果'發現在/ usr/include -name Python.h'。謝謝。 –

+0

感謝您的回覆。結果是**/usr/include/python2.7_d/Python.h /usr/include/python2.7/Python.h /usr/include/python2.6/Python.h /usr/include/python2 .6_d/Python.h ** – dhana

+0

因此,PIP完成的編譯過程出現問題。如果你看看'gcc'調用,你會看到'-I/usr/include/python3.2mu'。你的Python.h存在於很多目錄中,但不是指向'gcc'。奇怪的是,你正在編譯它反對** Python3.x **,而您的系統只有** Python 2.x **標題... –

回答

4

我想,這可能會解決你的問題:

sudo apt-get install python3-dev

但我不能保證,這將工作100%:-)