Trouble using PIL in Django app on Windows

喜夏-厌秋 提交于 2019-12-18 17:33:12

问题


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.


回答1:


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/




回答2:


This worked for me when the same installer (windows, Python2.7) downloaded from the official PIL site did not. Thanks!



来源:https://stackoverflow.com/questions/5352968/trouble-using-pil-in-django-app-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!