sci.misc.imread读取数据为空 或者 IOError: decoder zip not available decoder jpeg not available 解决办法
来源:互联网 发布:淘宝一手货源一件代发 编辑:程序博客网 时间:2024/06/05 08:25
一. 问题描述
前几天centOS服务器突然出现以下问题:
from scipy.misc import imreadimg= imread(jpg_file)img.shape
返回:
()输入:
img返回:
array(<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=870x1110 at 0x10BEC3F80>, dtype=object)
试着输入:
img= imread(jpg_file, 1)读入灰度图像,则会报错:
IOError: decoder jpeg not available
如果是png图像,则会报错:
IOError: decoder zip not available
二. 解决方法
在其它服务器上运行,则会正确输出img.shape以及img的数据。刚开始以为scipy安装出现了问题,重装以后问题仍在。后来根据网上一些帖子,又按照本服务器的配置,终于解决了。
步骤:
(1)卸载PIL
pip uninstall PIL如果觉得没有卸载彻底,可以再执行以下命令,删除残余文件:
rm -rf /usr/lib64/python2.6/site-packages/PILrm /usr/lib64/python2.6/site-packages/pil.pth(2) 加入必须的系统库
yum install zlib zlib-devel yum install libjpeg libjpeg-level yum install freetype freetype-devel(3)重新安装PIL
网上有采用:
pip install PIL但是这种方法会出现以下错误:
--- TKINTER support available*** JPEG support not available*** ZLIB (PNG/ZIP) support not available*** FREETYPE2 support not available*** LITTLECMS support not available建议采用下载安装包的方式来重装PIL:
wget http://effbot.org/downloads/Imaging-1.1.7.tar.gztar xvfz Imaging-1.1.7.tar.gzcd Imaging-1.1.7python setup.py build_ext -i输入上述命令,会有以下输出:
PIL 1.1.7 SETUP SUMMARY--------------------------------------------------------------------version 1.1.7platform linux2 2.6.6 (r266:84292, Jan 22 2014, 09:42:36) [GCC 4.4.7 20120313 (Red Hat 4.4.7-4)]----------------------------------------------------------------------- TKINTER support available--- JPEG support available--- ZLIB (PNG/ZIP) support available--- FREETYPE2 support available*** LITTLECMS support not available--------------------------------------------------------------------To add a missing option, make sure you have the requiredlibrary, and set the corresponding ROOT variable in thesetup.py script.To check the build, run the selftest.py script.TKINTER和LITTLECMS 可能出现不可用的情况,但是不影响PIL的使用。
最后输入:
python setup.py install重新测试问题示例,img.shape则会正确显示:
(870, 1110, 3)大功告成。
PS:
1. 在第三步重新安装PIL时,有教程说需要修改setup.py的相关路径:
TCL_ROOT = "/usr/lib64/"JPEG_ROOT = "/usr/lib64/"ZLIB_ROOT = "/usr/lib64/"TIFF_ROOT = "/usr/lib64/"FREETYPE_ROOT = "/usr/lib64/"LCMS_ROOT = "/usr/lib64/"但是这项更改,对于本机无效。如果你使用默认的路径无效,不妨参照这里 的结尾部分来修改这几个路径。
2. 由于之前服务器上安装了两个python版本,导致pip 等组件较为混乱,无法正常使用。给配置工作带来很多麻烦,以后电脑上最好只安装一个版本的python。
参考链接:
http://www.laonan.net/blog/57/
http://www.cnblogs.com/neolf/articles/2409118.html
http://www.yihaomen.com/article/python/286.htm
0 0
- sci.misc.imread读取数据为空 或者 IOError: decoder zip not available decoder jpeg not available 解决办法
- PIL IOError: decoder jpeg not available
- python PIL IOError: decoder jpeg not available
- Wiki - 解决 IOError: decoder jpeg not available
- centos6 python decoder jpeg not available解决办法
- PIL不能正常使用exceptions.IOError: decoder jpeg not available
- 修正pil错误 IOError: decoder zip not available
- ImportError: No module named Image IOError: decoder zip not available
- python程序运行报错 IOError: decoder zip not available
- PIL image 提示 decoder jpeg not available
- python(django) 使用PIL报错IOError at decoder jpeg not available
- python 使用PIL报错IOError at decoder jpeg not available
- python(django) 使用PIL报错IOError at decoder jpeg not available
- centos下python上传jpg格式图片报错问题IOError: decoder jpeg not available
- scrapy爬虫之错误 No module named PIL + IOError:decoder jpeg not available +PIL的安装
- Upload of image failed: decoder jpeg not available
- ubuntu 上OError: decoder jpeg not available问题解决
- mac 下解决OError: decoder jpeg not available问题
- LeetCode之Minimum Depth of Binary Tree
- cocos2d-x2.2 win7创建项目
- 黑马程序员--单例模式
- java-spring事务管理部分代码主要代码
- 前缀和--Openmp
- sci.misc.imread读取数据为空 或者 IOError: decoder zip not available decoder jpeg not available 解决办法
- Cstyle的札记,R&D必读手册,第4篇 Embedded Ethernet Controller
- WebKit专栏
- c# 互斥锁(Mutex)使用详解
- golang动态解析xml
- 数据结构-van emde boas 树
- 大电容并小电容
- UVA 409 - Excuses, Excuses!
- CodeForces - Domino Effect