python Image库 出错
来源:互联网 发布:哈登 nba数据 编辑:程序博客网 时间:2024/06/05 07:37
False decoder zip not available
IOError: cannot identify image file 'tmp_20.png'
在老大的注视下,问题一个接一个出现,然后虽然解决了,感觉不爽啊
首先问题是
--------------------------------------------------------------------PIL 1.1.7 SETUP SUMMARY--------------------------------------------------------------------version 1.1.7platform linux2 2.7.5+ (default, Sep 19 2013, 13:48:49) [GCC 4.8.1]--------------------------------------------------------------------*** TKINTER support not available*** JPEG support not available*** ZLIB (PNG/ZIP) support not available*** FREETYPE2 support not available*** LITTLECMS support not available--------------------------------------------------------------------
我保存成png文件不行,提示False decoder zip not available
在windows下运行的好好的,但是linux下就是不行,后来终于发现原来是我windows下不是用的PIL,而是PILLOW
看到这一片文章才发现http://wangye.org/blog/archives/752/
转载:
配置的Debian Web服务器,通过virtualenv构建了Pyramid项目,大部分代码运行挺正常,到一个验证码程序时出错了,检查日志得到如下Python异常:
ImportError: No module named PIL
但是我PIL明明是通过easy_install直接安装的啊,求助于网络找到了这么一篇解决方案《The problem with installing PIL using virtualenv or buildout》,原文的意思是在pypi上的PIL版本不兼容于setuptools,所以不能被easy_install正常安装,必须指定url安装兼容版本,比如如下命令:
pip install --no-index -f http://dist.plone.org/thirdparty/ -U PIL
经过这么一折腾,确实测试下来import PIL
不会报错了,但是原程序依旧不能正常运行,继续检查日志后得到下面的异常:
ImportError: The _imagingft C module is not installed
搜索了网络,大多是编译安装PIL时,系统缺少库文件导致的,通过下面的命令安装可能的包或者库文件:
sudo apt-get install libjpeg libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev
然后重新编译下载PIL,结果在这过程中提示如下警告:
--------------------------------------------------------------------*** TKINTER support not available (Tcl/Tk 8.4 libraries needed)*** JPEG support not available*** ZLIB (PNG/ZIP) support not available*** FREETYPE2 support not available--------------------------------------------------------------------To add a missing option, make sure you have the requiredlibrary, and set the corresponding ROOT variable in thesetup.py script.
所有的必须的库仍然提示support not available,说明刚才的安装预先库的办法是没有用的,纠结了。
搜索了网络,大多是针对Ubuntu的解决方案,不过功夫不负有心人,还是让我找到了Debian下的解决办法《PIL zip jpeg decoders not working on runtime but work on install/selftest》,现在分享出来:
其实最简单的办法就是先用命令pip uninstall PIL
卸载已有的PIL,然后安装PIL的fork版本Pillow,这是一个“友好”(friendly)的PIL版本,由Plone社区维护,主要用于Web开发上。
pip install pillow
好了,卸载先前的官方PIL,安装Pillow后,所有问题都解决了!
然后又出问题了这次是 cannot identify image file 'tmp_20.png'
这个是image库进行load的时候出问题,然后其实很简单就是
from PIL import Image
替换掉 import Image就可以了
- python Image库 出错
- python Image库操作
- python Image库
- Python安装Image库
- import Image 出错
- python image
- Python PIL库之Image注解(API)
- Python图像处理库 — Image类
- Python 图像处理库(PIL)--Image学习
- python第三方库PIL.Image安装
- python图形处理库PIL(Python Image Library)
- python图形处理库PIL(Python Image Library)的基本概念
- python 图像处理库模块(python Image Library)
- python图形处理库PIL(Python Image Library)的介绍
- IMAGE控件出错代替图片的JS
- canvas 执行canvas.toDataURL("image/png"); 出错
- scikit-image安装出错及解决
- python-Image处理图片
- lvs+ldirectord
- 算法之逆序对问题求解
- HDU 2553 N皇后问题
- linux tree 命令
- 十个海量数据处理方法大总结
- python Image库 出错
- 大数据量下的数据库查询与插入如何优化? (整理)
- Ubuntu的软件都安装到哪里去了
- Android支付接入(一):支付宝
- 有关递归
- 第191天
- Obey the general contract when overriding equals
- hdu2158 最短区间版大家来找碴
- Android支付接入(二):移动游戏基地