加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python-2.7 – IOError:OS X 10.10上没有编码器jpeg

发布时间:2020-12-20 13:50:07 所属栏目:Python 来源:网络整理
导读:我试图安装 Python Image Library,并且有消息告诉我安装成功 -------------------------------------------------------------------- PIL 1.1.7 SETUP SUMMARY -------------------------------------------------------------------- version 1.1.7 platfo
我试图安装 Python Image Library,并且有消息告诉我安装成功

--------------------------------------------------------------------
    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,[("jpeg",(0,0)+im.size,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

解决方法

我通过使用Pillow而不是PIL解决了这个问题,并使用“form PIL import Image”而不是“import Image”.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读