Pillow-PIL的完全Fok替代库--完美解决报错The _imagingft C module is not installed的解决方案
来源:互联网 发布:淘宝兄弟体育是正品么 编辑:程序博客网 时间:2024/05/16 01:26
问题
在学习PIL(Python Image Library),由于代码里用到了PIL库处理验证码。
出现可著名的
The _imagingft C module is not installed
原因解析
原因是因为没有安装对应的图片和处理字体的包
解决办法就是先卸载PIL的包,然后安装需要的库,接着重装PIL
linux下的解决办法
linux下还是比较好解决的
卸载PIL
pip uninstall pil
安装对应的包
sudo apt-get install libjpeg-develsudo apt-get install freetype-develsudo apt-get install libpng-devel
之后重装PIL即可
pip install pil
windows下
但是在window下就没那么好解决了。
这个我只能说呵呵,但是花点时间还是能找到解决办法的
那就是pillow
下面我们就着重讲解一下。
Pillow
Pillow 是 PIL 的替代版本,PIL 软件包提供了基本的图像处理功能,如:改变图像大小,旋转图像,图像格式转换,色场空间转换,图像增强,直方图处理,插值和滤波等等。
主页 http://pillow.readthedocs.org/en/latest/
Pillow 为了解决 PIL 的两个问题:
1. 不兼容 setuptools
2. 报告的问题太多,而更新太慢
因此我们只需要卸载掉pil而,转战pillow即可
注意
在解决的过程中发现了一个windows下Python库的包镜像站
http://www.lfd.uci.edu/~gohlke/pythonlibs/
这里是一些第三方组织编译的EXE包, 要下载对应PY版本的PIL-pillow, 重新安装, 最好下载Pillow, 它是对PIL的一些BUG修正后的编译版
安装前,可以先 pip uninstall pil
安装Pillow后, 可能还会发生KeyError
的错误, 检查项目源码后发现是 Image 模块的save函数中 , 处理图片文件格式时报的错.
不管是”JPEG”, 还是”GIF”, 都会报错, 解决的办法是:
把项目源码中 import Image
, 替换成from PIL import Image
即可.
按这个原理, 项目中所有用到 Image 模块的地方都应该替换掉.
官网的说法
Use from PIL import Image
instead of import Image
.
另外如果安装出错
ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting
一样原因还是缺少库
参照
Fail during installation of Pillow (Python module) in Linux
Ubuntu 12.04 LTS or Raspian Wheezy 7.0
sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk
Ubuntu 14.04
sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
CentOS/Fedora 20
sudo yum install libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel
- Pillow-PIL的完全Fok替代库--完美解决报错The _imagingft C module is not installed的解决方案
- 解决Windows下PIL库的"The _imagingft C module is not installed"错误
- Python 的PIL,可以解决ImportError The _imagingft C module is not installed
- PIL写入字体出现ImportError:The _imagingft C module is not installed 错误的解决方法
- python PIL ImportError: The _imagingft C module is not installed
- PIL “The _imagingft C module is not installed” 错误补救
- Python图片处理PIL/pillow/生成验证码/出现KeyError: 和The _imagingft C module is not installed
- python中PIL库在使用时出现The _imagingft C module is not installed错误
- Python: The _imagingft C module is not installed错误的解决
- The _imagingft C module is not installed
- PIL报错:The _imaging C module is not installed
- Windows系统下,报错The _imagingft C module is not installed
- 用pil产生验证码出现:ImportError: The _imagingft C module is not installed
- ImportError:The _imagingft C module is not installed 错误的解决方法
- ImportError: The _imagingft C module is not installed
- ImportError: The _imagingft C module is not installed
- ImportError: The _imagingft C module is not installed
- ImportError: The _imagingft C module is not installed
- LT29i刷机方法
- 算法设计题2.39~2.40-线性表-第2章-《数据结构习题集》-严蔚敏吴伟民版
- THREEJS阴影效果
- 递归之---汉诺塔
- 【Light】[1078]Integer Divisibility
- Pillow-PIL的完全Fok替代库--完美解决报错The _imagingft C module is not installed的解决方案
- MyBatis学习总结(一)——MyBatis快速入门(转发)
- JSON 字符串转换为 JavaScript 对象
- QT QSplitter随窗口自适应大小(Autosize)
- getchar() 与getch()
- 【重走普及路】【贪心】合并果子
- JSP指令与动作元素
- 浅谈递归
- Http相关--文件上传