我正在尝试安装Python图像库,但收到消息告诉我安装成功
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7
platform darwin 2.6.9 (unknown, Sep 9 2014, 15:05:12)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- FREETYPE2 support available
*** LITTLECMS support not available
--------------------------------------------------------------------
但是当我运行代码时,我得到了一些错误消息,可能告诉我我还没有安装JPEG库
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/tian/PycharmProjects/helloworld/image_test.py
Traceback (most recent call last):
File "/Users/tian/PycharmProjects/helloworld/image_test.py", line 35, in <module>
image.save('code.jpg', 'jpeg')
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 1439, in save
save_handler(self, fp, filename)
File "/Library/Python/2.7/site-packages/PIL/JpegImagePlugin.py", line 471, in _save
ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
File "/Library/Python/2.7/site-packages/PIL/ImageFile.py", line 495, in _save
e = Image._getencoder(im.mode, e, a, im.encoderconfig)
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 401, in _getencoder
raise IOError("encoder %s not available" % encoder_name)
IOError: encoder jpeg not available
当我在Google中搜索这个错误的原因时,大多数的解决方案都是重新安装PIL,但当我安装PIL时,我得到了"JPEG支持可用“的消息,所以它应该不是由JPEG库引起的。那么,我该如何解决这个问题呢?
我的操作系统是OS X Yosemite 10.10
发布于 2015-05-27 11:34:14
我用Pillow代替PIL来解决这个问题,用"form PIL import Image“代替"import Image”。
https://stackoverflow.com/questions/30472278
复制相似问题