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

时间:2010-06-03 15:10:28

标签: python gcc python-imaging-library virtualenv

我使用--no-site-packages选项创建了virtualenv。尝试安装PIL时出错:

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

有人可以帮我这个吗?

我正在运行Ubuntu 10.04(64位)

3 个答案:

答案 0 :(得分:81)

您需要安装python-dev软件包。

sudo apt-get install python-dev

答案 1 :(得分:3)

查看您的pastebin链接上的完整列表

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

是问题。

gcc命令行有

-I/usr/include/python2.6

这样就可以找到它,而这就是我的Mandriva系统所在的位置。

也许您已经安装了python,但是没有开发库会出现在相应的“-devel”版本的软件包中?

答案 2 :(得分:0)

sudo apt-get install python-dev - 非常好,但是 如果你在主机系统上使用很少的pythons,并且python2.6是默认的。

如果您尝试:

 virtualenv -p python2.7

,转到bin目录,比如source activate, 比:

pip install PIL

你得到这样的错误:_imaging.c:75:20:错误:Python.h:没有这样的文件或目录

你应该说!:

sudo apt-get install python2.7-dev