I am following a Django tutorial that involves image uploading, and have run into this problem. I tried installing and reinstalling PIL, libjpeg, and libfreetype6 several times, but nothing so far seems to be working. I have spent several hours trying to find a solution, and am very frustrated at this point. Please help.
我正在关注涉及图像上传的Django教程,并遇到了这个问题。我尝试了多次安装和重新安装PIL,libjpeg和libfreetype6,但到目前为止似乎没有任何工作。我花了几个小时试图找到解决方案,在这一点上非常沮丧。请帮忙。
Here is the result of selftest.py after I reinstall PIL on my mac:
这是我在我的mac上重新安装PIL后selftest.py的结果:
PIL 1.1.6 BUILD SUMMARY
--------------------------------------------------------------------
version 1.1.6
platform darwin 2.7.3 (v2.7.3:70274d53c1dd, Apr 9 2012, 20:52:43)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)]
--------------------------------------------------------------------
--- TKINTER support ok
*** JPEG support not available
--- ZLIB (PNG/ZIP) support ok
*** FREETYPE2 support not available
--------------------------------------------------------------------
To add a missing option, make sure you have the required
library, and set the corresponding ROOT variable in the
setup.py script.
To check the build, run the selftest.py script.
rrdhcp-10-32-44-157:Imaging-1.1.6 pfg$ python selftest.py
*****************************************************************
Failure in example: _info(Image.open("Images/lena.jpg"))
from line #24 of selftest.testimage
Exception raised:
Traceback (most recent call last):
File "./doctest.py", line 499, in _run_examples_inner
exec compile(source, "<string>", "single") in globs
File "<string>", line 1, in <module>
File "./selftest.py", line 22, in _info
im.load()
File "PIL/ImageFile.py", line 180, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "PIL/Image.py", line 375, in _getdecoder
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg not available
1 items had failures:
1 of 57 in selftest.testimage
***Test Failed*** 1 failures.
*** 1 tests of 57 failed.
4 个解决方案
#1
41
There are several cases with PIL which lead to a similar experience. If you have installed PIL out of a virtualenv using
PIL有几种情况可以带来类似的体验。如果您使用了virtualenv安装了PIL
pip install PIL
Then you should have installed the dev versions of libjpeg, libz before. Assuming you're on a Ubuntu box, a
那你应该先安装libjpeg,libz的开发版本。假设你在Ubuntu盒子上,一个
pip uninstall PIL
apt-get install libjpeg-dev zlib1g-dev libpng12-dev
pip install PIL
should suffice. You could also install Pillow instead of PIL, it works better with setuptools and can be installed in a virtualenv.
应该足够了。您也可以安装Pillow而不是PIL,它可以更好地使用setuptools,并且可以安装在virtualenv中。
#2
7
I found this worked fine for me:
我发现这对我来说很好:
pip uninstall PIL
pip install Pillow
then I restarted the server:
然后我重新启动了服务器:
kill -HUP XXX
where XXX is the process ID of the your server process.
其中XXX是您的服务器进程的进程ID。
#3
4
I was already using Pillow
and got the same error. Tried installing libjpeg
or libjpeg-dev
as suggested by others but was told that a (newer) version was already installed.
我已经在使用Pillow并得到了同样的错误。尝试按照其他人的建议安装libjpeg或libjpeg-dev,但被告知已经安装了(较新的)版本。
In the end all it took was reinstalling Pillow
:
最后所需要的只是重新安装枕头:
sudo pip uninstall Pillow
sudo pip install Pillow
#4
0
In case you are using Fedora, please do, before doing a pip install Pillow:
如果你正在使用Fedora,请在做pip安装Pillow之前做:
yum install libjpeg-devel zlib1g-devel libpng12-devel
#1
41
There are several cases with PIL which lead to a similar experience. If you have installed PIL out of a virtualenv using
PIL有几种情况可以带来类似的体验。如果您使用了virtualenv安装了PIL
pip install PIL
Then you should have installed the dev versions of libjpeg, libz before. Assuming you're on a Ubuntu box, a
那你应该先安装libjpeg,libz的开发版本。假设你在Ubuntu盒子上,一个
pip uninstall PIL
apt-get install libjpeg-dev zlib1g-dev libpng12-dev
pip install PIL
should suffice. You could also install Pillow instead of PIL, it works better with setuptools and can be installed in a virtualenv.
应该足够了。您也可以安装Pillow而不是PIL,它可以更好地使用setuptools,并且可以安装在virtualenv中。
#2
7
I found this worked fine for me:
我发现这对我来说很好:
pip uninstall PIL
pip install Pillow
then I restarted the server:
然后我重新启动了服务器:
kill -HUP XXX
where XXX is the process ID of the your server process.
其中XXX是您的服务器进程的进程ID。
#3
4
I was already using Pillow
and got the same error. Tried installing libjpeg
or libjpeg-dev
as suggested by others but was told that a (newer) version was already installed.
我已经在使用Pillow并得到了同样的错误。尝试按照其他人的建议安装libjpeg或libjpeg-dev,但被告知已经安装了(较新的)版本。
In the end all it took was reinstalling Pillow
:
最后所需要的只是重新安装枕头:
sudo pip uninstall Pillow
sudo pip install Pillow
#4
0
In case you are using Fedora, please do, before doing a pip install Pillow:
如果你正在使用Fedora,请在做pip安装Pillow之前做:
yum install libjpeg-devel zlib1g-devel libpng12-devel