Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble using PIL in Django app on Windows

I'm learning a little Django with the Python Web Development with Django book. All was going well until I tried to build the photos application which requires the PIL (Python Imaging Library). When I try to add an image through the admin interface I receive an error message pasted below.

I am running Windows 7, Python 2.7, Django 1.3b1, and XAMPP 1.7.3 with the wsgi module successfully installed (at least I think so, since the rest of my Django experiments work fine).

Following the troubleshooting guide from the PIL site I have tried to import the PIL modules at the Python prompt:

>>>import _imaging
>>>import Image

Both work fine, without displaying an error. However, trying to run the Django admin app that uses PIL results in:

ImportError at /admin/items/photo/add/ The _imaging C module is not installed Request Method: POST Request URL: http://localhost:8888/photos/admin/items/photo/add/ Django Version: 1.3 beta 1 SVN-15679 Exception Type: ImportError Exception Value:
The _imaging C module is not installed Exception Location: C:\Python27\lib\site-packages\PIL\Image.py in getattr, line 37 Python Executable: C:\xampp\apache\bin\httpd.exe Python Version: 2.7.0 Python Path:
['C:\Python27\lib\site-packages\ipython-0.10-py2.7.egg', 'C:\Python27\lib\site-packages\sqlalchemy-0.6.4-py2.7.egg', 'C:\Python27\lib\site-packages\openglcontext_full-2.1.0a7-py2.7.egg', 'C:\Python27\lib\site-packages\ttfquery-1.0.4-py2.7.egg', 'C:\Python27\lib\site-packages\fonttools-2.3-py2.7-win32.egg', 'C:\Python27\lib\site-packages\pydispatcher-2.0.2-py2.7.egg', 'C:\Python27\lib\site-packages\pyside-1.0.0beta1qt471-py2.7-win32.egg', 'C:\code\ots', 'C:\lib\django', 'C:\code', 'C:\xampp', 'C:\Windows\system32\python27.zip', 'C:\Python27\Lib', 'C:\Python27\DLLs', 'C:\Python27\Lib\lib-tk', 'C:\xampp\apache\bin', 'C:\Users\garethconner\AppData\Roaming\Python\Python27\site-packages', 'C:\Python27', 'C:\Python27\lib\site-packages', 'C:\Python27\lib\site-packages\PIL', 'C:\lib\django\django', 'C:\Python27\lib\site-packages\win32', 'C:\Python27\lib\site-packages\win32\lib', 'C:\Python27\lib\site-packages\Pythonwin', 'C:\Python27\lib\site-packages\setuptools-0.6c11-py2.7.egg-info', 'C:\Python27\lib\site-packages\wx-2.9.1-msw', 'C:\code']

Any help would be greatly appreciated.

like image 201
gbc Avatar asked Feb 25 '23 18:02

gbc


1 Answers

I've answered this before here

Just install pre-compiled binaries for Windows (for your python version) from http://www.lfd.uci.edu/~gohlke/pythonlibs/

like image 103
Imran Avatar answered Feb 27 '23 08:02

Imran