【问题标题】:How to install python cairo?如何安装 python cairo?
【发布时间】:2013-06-13 10:52:37
【问题描述】:

我是 python3 的新手。我已经创建了虚拟环境。我尝试使用 pip 命令安装 pycairo 包。我需要安装 python cairo。请参阅以下信息

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

但我得到了错误。请解决我的问题。谢谢

【问题讨论】:

  • 您能否发布命令find /usr/include -name Python.h 的结果。谢谢。
  • 感谢您的回复。结果是 /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
  • 所以,PIP 完成的编译过程有问题。如果您查看gcc 调用,您将看到-I/usr/include/python3.2mu。您的Python.h 存在于许多目录中,但没有指向gcc。奇怪的是,您正在准备针对 Python3.x 编译它,而您的系统只有 Python 2.x... 的标头
  • 谢谢,我已经使用 sudo apt-get install python3-dev 解决了我的问题。并将 Python.h 文件附加到 python3.2mu

标签: python python-3.x pycairo


【解决方案1】:

我认为这可能会解决您的问题:

sudo apt-get install python3-dev

但我不能保证这会 100% 起作用:-)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多