2010-06-03 45 views
42

Tôi đã tạo một virtualenv với tùy chọn --no-site-packages. Tôi nhận được một lỗi khi cố gắng cài đặt PIL:lỗi gcc khi cài đặt PIL trong Python2.6 virtualenv

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 

Ai đó có thể giúp tôi với điều này?

Tôi đang chạy Ubuntu 10.04 (64 bit)

Trả lời

81

Bạn cần cài đặt gói python-dev.

sudo apt-get install python-dev 
+5

Tôi đang ở trong môi trường Windows 7. Làm thế nào để tôi cài đặt python-dev? – darren

+4

Tôi phải cài đặt 'python2.6-dev' trong trường hợp của mình vì virtualenv đang sử dụng 2.6. Chỉ cần một người đứng đầu cho bất cứ ai khác – agscala

+4

'yum cài đặt python-devel' nếu bạn đang ở trên CentOS/RHEL. – Banjer

3

Nhìn vào danh sách đầy đủ vào liên kết pastebin bạn dòng

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

là vấn đề.

Dòng lệnh gcc có

-I/usr/include/python2.6 

có do đó sẽ là nơi nó sẽ mong đợi để tìm thấy nó và đó là nơi mà nó là trên hệ thống Mandriva tôi.

Có lẽ bạn đã cài đặt python nhưng không phải thư viện phát triển sẽ nằm trong phiên bản "-devel" tương ứng của gói?

0

sudo apt-get install python-dev - là rất tốt, nhưng nếu bạn sử dụng vài con trăn trên hệ thống máy chủ của bạn, và python2.6 là mặc định.

Nếu bạn cố gắng:

virtualenv -p python2.7 

, đi đến thư mục bin, nói nguồn kích hoạt, hơn:

pip install PIL 

Bạn nhận được lỗi như thế này: _imaging.c: 75: 20 : lỗi: Python.h: Không có tập tin hoặc thư mục

Bạn nên nói !:

sudo apt-get install python2.7-dev 
Các vấn đề liên quan