windows 如何修复“未安装 _imaging C 模块”Django/WSGI/Apache
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6397509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix "The _imaging C module is not installed" Django/WSGI/Apache
提问by leech
I run my test sites on my home computer which sadly uses Windows. Now, i'm trying to thumbnail an image but i'm getting the error:
我在使用 Windows 的家用计算机上运行我的测试站点。现在,我正在尝试缩略图图像,但出现错误:
The _imaging C module is not installed
But only when i try to access the view via the Apache server. Runserver thumbnails just fine. I've installed the special precomplied binaries that others have referenced, but haven't had any luck.
但仅当我尝试通过 Apache 服务器访问视图时。运行服务器缩略图就好了。我已经安装了其他人引用的特殊预编译二进制文件,但没有任何运气。
Any Idea why it works in runserver/shell but not Apache?
知道为什么它可以在 runserver/shell 中运行而不是在 Apache 中运行吗?
回答by fijter
You need to have the path to PIL in and the other site-packages in your path in your .wsgi configuration file. So first you need to find the location of your site-packages (for example: /usr/local/lib/python2.6/site-packages/), then add it to your sys.path in your .wsgi file. Example WSGI:
您需要在 .wsgi 配置文件的路径中包含 PIL 的路径和其他站点包。因此,首先您需要找到站点包的位置(例如:/usr/local/lib/python2.6/site-packages/),然后将其添加到 .wsgi 文件中的 sys.path 中。示例 WSGI:
import os, sys
sys.path.append('/home/www/sites/mysite', '/usr/local/lib/python2.6/site-packages/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
回答by boatcoder
I had the same problem under mod_wsgi on apache on windows server 2008. PIL would load from my virtualenv just fine, but would not load under mod_wsgi, even with the right version of msvcr90.dll in the folder with the .pyd files.
我在 windows server 2008 上的 apache 上的 mod_wsgi 下遇到了同样的问题。 PIL 会从我的 virtualenv 加载得很好,但不会在 mod_wsgi 下加载,即使在包含 .pyd 文件的文件夹中使用正确版本的 msvcr90.dll。
The answer for me has to do with WINDOWS SXS HELL and a patch that planders created.
我的答案与 WINDOWS SXS HELL 和 planders 创建的补丁有关。
I had to edit my distutils\msvc9compiler.py and comment out one line (I'm using Python 2.7, he was using 2.6.x), delete the build folder and rebuild PIL, and everything worked.
我不得不编辑我的 distutils\msvc9compiler.py 并注释掉一行(我使用的是 Python 2.7,他使用的是 2.6.x),删除构建文件夹并重建 PIL,一切正常。
http://groups.google.com/group/isapi_wsgi-dev/browse_thread/thread/03fa2b485ec2281d?pli=1
http://groups.google.com/group/isapi_wsgi-dev/browse_thread/thread/03fa2b485ec2281d?pli=1
I don't know who he is, but I am very grateful.
我不知道他是谁,但我很感激。
回答by tdolydong
1.you should check _imaging.pyc or _imaging.dll or _imaging.so in you computer.
1.您应该检查您计算机中的_imaging.pyc 或_imaging.dll 或_imaging.so。
2.Exist!now, try to import Image
2.存在!现在,尝试 import Image
3.Right!try to import _imaging
3.对!试试 import _imaging
if error, checking you computer is 32bit or 64bit.
如果出错,请检查您的计算机是 32 位还是 64 位。
if you computer is 32bit ,you should install some package like PIL-1.1.7.win32-py2.5 http://effbot.org/downloads/PIL-1.1.7.win32-py2.5.exe
如果您的计算机是 32 位,则应该安装一些软件包,例如 PIL-1.1.7.win32-py2.5 http://effbot.org/downloads/PIL-1.1.7.win32-py2.5.exe
if you computer is 64bit, you should install some package like PIL-1.1.7.win-amd64-py2.5 and you can found here:http://www.lfd.uci.edu/~gohlke/pythonlibs/
如果你的电脑是 64 位,你应该安装一些像 PIL-1.1.7.win-amd64-py2.5 这样的包,你可以在这里找到:http://www.lfd.uci.edu/~gohlke/pythonlibs/
4.install the right package on site-packeges,it's will be running
4.在site-packeges上安装正确的包,它将运行
GOOD LUCK!
祝你好运!