42

我用 --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 位)

4

3 回答 3

80

您需要安装 python-dev 包。

sudo apt-get install python-dev
于 2010-06-03T15:47:20.350 回答
3

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

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

是问题所在。

gcc 命令行有

-I/usr/include/python2.6

那里就是它期望找到它的地方,这就是它在我的 Mandriva 系统上的位置。

也许您安装了 python,但没有安装相应的“-devel”版本包中的开发库?

于 2010-06-03T15:45:03.313 回答
0

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

如果您尝试:

 virtualenv -p python2.7

,去bin目录,说source activate,比:

pip install PIL

你会得到这样的错误:_imaging.c:75:20: error: Python.h: No such file or directory

你应该说!:

sudo apt-get install python2.7-dev
于 2013-11-29T11:53:43.413 回答