简体   繁体   English

尝试在Python2.6 virtualenv中安装PIL时出现gcc错误

[英]gcc error trying to install PIL in a Python2.6 virtualenv

I have created a virtualenv with the --no-site-packages option. 我用--no-site-packages选项创建了一个virtualenv。 I get an error trying to install PIL: 我在尝试安装PIL时遇到错误:

http://pastebin.com/SVqxs1sC http://pastebin.com/SVqxs1sC

...
error: command '/usr/bin/gcc' failed with exit status 1

----------------------------------------
Command /home/dustin/.virtualenvs/django1.2/bin/python -c "import setuptools; __file__='/home/dustin/.virtualenvs/django1.2/build/pil/setup.py'; execfile('/home/dustin/.virtualenvs/django1.2/build/pil/setup.py')" install --single-version-externally-managed --record /tmp/pip-t_oikl-record/install-record.txt --install-headers /home/dustin/.virtualenvs/django1.2/include/site/python2.6 failed with error code 1
Exception information:
Traceback (most recent call last):
  File "/home/dustin/.virtualenvs/django1.2/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/basecommand.py", line 120, in main
    self.run(options, args)
  File "/home/dustin/.virtualenvs/django1.2/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/commands/install.py", line 165, in run
    requirement_set.install(install_options)
  File "/home/dustin/.virtualenvs/django1.2/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/req.py", line 1243, in install
    requirement.install(install_options)
  File "/home/dustin/.virtualenvs/django1.2/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/req.py", line 540, in install
    cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False)
  File "/home/dustin/.virtualenvs/django1.2/lib/python2.6/site-packages/pip-0.7.2-py2.6.egg/pip/__init__.py", line 226, in call_subprocess
    % (command_desc, proc.returncode))
InstallationError: Command /home/dustin/.virtualenvs/django1.2/bin/python -c "import setuptools; __file__='/home/dustin/.virtualenvs/django1.2/build/pil/setup.py'; execfile('/home/dustin/.virtualenvs/django1.2/build/pil/setup.py')" install --single-version-externally-managed --record /tmp/pip-t_oikl-record/install-record.txt --install-headers /home/dustin/.virtualenvs/django1.2/include/site/python2.6 failed with error code 1

Can someone help me with this? 有人可以帮我弄这个吗?

I'm running Ubuntu 10.04 (64 bit) 我正在运行Ubuntu 10.04(64位)

你需要安装python-dev包。

sudo apt-get install python-dev

Looking at the full listing on your pastebin link the line 查看您的pastebin链接上的完整列表

_imaging.c:75:20: error: Python.h: No such file or directory

is the problem. 是问题。

The gcc command line has gcc命令行有

-I/usr/include/python2.6

there so that would be where it would expect to find it and that's where it is on my Mandriva system. 那就是它会期望找到它的位置,而这就是我的Mandriva系统所在的位置。

Perhaps you have python installed but not the development libraries which would be in the corresponding "-devel" version of the package? 也许你已经安装了python但是没有开发库,它们会在相应的“-devel”版本的软件包中?

sudo apt-get install python-dev - is very good, but if you use few pythons on your host system, and python2.6 is default. sudo apt-get install python-dev - 非常好,但是如果你在主机系统上使用很少的pythons,那么python2.6是默认的。

If you try to: 如果您尝试:

 virtualenv -p python2.7

, go to the bin directory, say source activate, than: ,转到bin目录,比如source activate,然后:

pip install PIL

You get error like this: _imaging.c:75:20: error: Python.h: No such file or directory 你得到这样的错误:_imaging.c:75:20:错误:Python.h:没有这样的文件或目录

You should say!: 你应该说!:

sudo apt-get install python2.7-dev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM