在 Windows 上的 Django 应用程序中使用 PIL 时出现问题
我正在通过 Python Web Development with Django 一书学习一点 Django。一切都很顺利,直到我尝试构建需要 PIL(Python 图像库)的照片应用程序。当我尝试通过管理界面添加图像时,我收到下面粘贴的错误消息。
我正在运行 Windows 7、Python 2.7、Django 1.3b1 和 XAMPP 1.7.3,并成功安装了 wsgi 模块(至少我这么认为,因为我的 Django 实验的其余部分工作正常)。
按照 PIL 站点的故障排除指南,我尝试在 Python 提示符下导入 PIL 模块:
>>>import _imaging
>>>import Image
两者都工作正常,没有显示错误。但是,尝试运行使用 PIL 的 Django 管理应用程序会导致:
/admin/items/photo/add/ 处导入错误 _imaging C 模块未安装 请求方式:POST 请求网址: http://localhost:8888/photos/admin/items/photo/添加/ Django 版本:1.3 beta 1 SVN-15679 异常类型:导入错误 异常值:
_imaging C 模块未安装 异常位置:getattr 中的 C:\Python27\lib\site-packages\PIL\Image.py,第 37 行 Python 可执行文件:C:\xampp\apache\bin\httpd.exe Python版本:2.7.0 Python路径:
['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:\代码\ots', 'C:\lib\django', 'C:\代码', '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:\代码']
任何帮助将不胜感激。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我之前这里回答过这个
问题从 http://www.windows 系统安装预编译的二进制文件(针对你的 python 版本)。 lfd.uci.edu/~gohlke/pythonlibs/
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/
当从官方 PIL 站点下载的相同安装程序(Windows、Python2.7)不起作用时,这对我有用。谢谢!
This worked for me when the same installer (windows, Python2.7) downloaded from the official PIL site did not. Thanks!