如何安装PIL--*** TKINTER support not available---IOError: cannot identify image file
2014-11-20 16:19
459 查看
问题一: *** TKINTER support not available
解决:
问题二:如何安装PIL
原文见:http://cn-popeye.iteye.com/blog/1236691
转载如下:
PIL是python理想的图片处理module,但是想要良好的支持各种图片,还需要检查一下几步,否则会提示:IOError: decoder jpeg not available之类的。
我的环境:Linux mint 11 amd64 / Python2.7
第一步:安装zlib png freetype jpeg
install zlib (ubuntu 官方源没有zlib,别想apt-get了)
下载zlib,(zlib.net已墙,可以去SF.net),
url: http://sourceforge.net/projects/libpng/files/zlib/1.2.5/zlib-1.2.5.tar.gz/download?use_mirror=superb-dca2
shell:
$ tar -xvzf zlib-1.2.5.tar.gz$ cd zlib-1.2.5$ ./configure --prefix=/usr/local$ make$ sudo make install
install png(忘记apt-get吧)
shell:
$ wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.5.6.tar.gz (如果文件不存在就浏览 /src/目录查找一下最新版)
$ tar -xvzf libpng-1.5.6.tar.gz
$ cd libpng-1.5.6
$ ./configure --prefix=/usr/local
$ make $ sudo make install
install freetype (忘记apt-get吧)
shell:
$ wget http://nchc.dl.sourceforge.net/project/freetype/freetype2/2.4.7/freetype-2.4.7.tar.gz
$ tar -xvzf freetype-2.4.7.tar.gz
$ cd freetype-2.4.7/
$ ./configure --prefix=/usr/local
$ make $ make install
install jpeg (忘记apt-get吧)
shell:
$ wget http://www.ijg.org/files/jpegsrc.v8c.tar.gz
$ tar -xvzf jpegsrc.v8c.tar.gz
$ cd jpeg-8c/
$ ./configure --prefix=/usr/local
$ make $ sudo make install
第二步:安装需要的 devel库(现在是想起apt-get的时候了)
shell:
$ sudo apt-get install libjpeg8-dev
$ sudo apt-get install libpng12-dev
$ sudo apt-get install libfreetype6-dev
$ sudo apt-get install zlib1g-dev
第三步:安装 PIL( Python Imaging Library )
shell 写道
$ wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
$ tar -xvzf Imaging-1.1.7.tar.gz
$ cd Imaging-1.1.7/
修改setup.py文件:
$ nano setup.py修改如下:
JPEG_ROOT = "/usr/local/lib"
ZLIB_ROOT = "/usr/local/lib"
FREETYPE_ROOT = "/usr/local/lib"
检查是否支持:
$ python setup.py build_ext -irunning build_ext
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7platform linux2 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)[GCC 4.5.2]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available -----------------------> OK!
--- ZLIB (PNG/ZIP) support available -----------------------> OK!
--- FREETYPE2 support available -----------------------> OK!
*** 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.
正式安装:
$ python setup.py build
$ sudo python setup.py install
最后一步:验证
Python代码
![](https://oscdn.geek-share.com/Uploads/Images/Content/201912/08/2bd88fd4ea07ac4aa5f1887f6a4d237e.png)
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import Image
picPath = '~/images/1212.jpg'
im = Image.open(picPath)
print im.getbbox()
输出结果图片尺寸:
(0, 0, 600, 715)
问题三:ImportError: libjpeg.so.8: cannot open shared object file: No such file or directory
解决:
问题四:PIL IOError: cannot identify image file 'images/1212.jpg'的解决办法
instead of
import Image
最后,贴上我的测试和结果:
aa.py:
结果:
PIL 1.1.7 SETUP SUMMARY -------------------------------------------------------------------- version 1.1.7 platform linux2 2.7.6 (default, Nov 11 2014, 16:55:01) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] -------------------------------------------------------------------- *** TKINTER support not available --- JPEG support available --- ZLIB (PNG/ZIP) support available --- FREETYPE2 support available --- LITTLECMS support available -------------------------------------------------------------------- To add a missing option, make sure you have the required library, and set the corresponding ROOT variable in the setup.py script.
解决:
apt-get install libjpeg libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev (无用)
pip install pillow
问题二:如何安装PIL
原文见:http://cn-popeye.iteye.com/blog/1236691
转载如下:
PIL是python理想的图片处理module,但是想要良好的支持各种图片,还需要检查一下几步,否则会提示:IOError: decoder jpeg not available之类的。
我的环境:Linux mint 11 amd64 / Python2.7
第一步:安装zlib png freetype jpeg
install zlib (ubuntu 官方源没有zlib,别想apt-get了)
下载zlib,(zlib.net已墙,可以去SF.net),
url: http://sourceforge.net/projects/libpng/files/zlib/1.2.5/zlib-1.2.5.tar.gz/download?use_mirror=superb-dca2
shell:
$ tar -xvzf zlib-1.2.5.tar.gz$ cd zlib-1.2.5$ ./configure --prefix=/usr/local$ make$ sudo make install
install png(忘记apt-get吧)
shell:
$ wget ftp://ftp.simplesystems.org/pub/libpng/png/src/libpng-1.5.6.tar.gz (如果文件不存在就浏览 /src/目录查找一下最新版)
$ tar -xvzf libpng-1.5.6.tar.gz
$ cd libpng-1.5.6
$ ./configure --prefix=/usr/local
$ make $ sudo make install
install freetype (忘记apt-get吧)
shell:
$ wget http://nchc.dl.sourceforge.net/project/freetype/freetype2/2.4.7/freetype-2.4.7.tar.gz
$ tar -xvzf freetype-2.4.7.tar.gz
$ cd freetype-2.4.7/
$ ./configure --prefix=/usr/local
$ make $ make install
install jpeg (忘记apt-get吧)
shell:
$ wget http://www.ijg.org/files/jpegsrc.v8c.tar.gz
$ tar -xvzf jpegsrc.v8c.tar.gz
$ cd jpeg-8c/
$ ./configure --prefix=/usr/local
$ make $ sudo make install
第二步:安装需要的 devel库(现在是想起apt-get的时候了)
shell:
$ sudo apt-get install libjpeg8-dev
$ sudo apt-get install libpng12-dev
$ sudo apt-get install libfreetype6-dev
$ sudo apt-get install zlib1g-dev
第三步:安装 PIL( Python Imaging Library )
shell 写道
$ wget http://effbot.org/downloads/Imaging-1.1.7.tar.gz
$ tar -xvzf Imaging-1.1.7.tar.gz
$ cd Imaging-1.1.7/
修改setup.py文件:
$ nano setup.py修改如下:
JPEG_ROOT = "/usr/local/lib"
ZLIB_ROOT = "/usr/local/lib"
FREETYPE_ROOT = "/usr/local/lib"
检查是否支持:
$ python setup.py build_ext -irunning build_ext
--------------------------------------------------------------------
PIL 1.1.7 SETUP SUMMARY
--------------------------------------------------------------------
version 1.1.7platform linux2 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)[GCC 4.5.2]
--------------------------------------------------------------------
*** TKINTER support not available
--- JPEG support available -----------------------> OK!
--- ZLIB (PNG/ZIP) support available -----------------------> OK!
--- FREETYPE2 support available -----------------------> OK!
*** 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.
正式安装:
$ python setup.py build
$ sudo python setup.py install
最后一步:验证
Python代码
![](https://oscdn.geek-share.com/Uploads/Images/Content/201912/08/2bd88fd4ea07ac4aa5f1887f6a4d237e.png)
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import Image
picPath = '~/images/1212.jpg'
im = Image.open(picPath)
print im.getbbox()
输出结果图片尺寸:
(0, 0, 600, 715)
问题三:ImportError: libjpeg.so.8: cannot open shared object file: No such file or directory
解决:
<span style="font-size:18px;">whereis Python export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib/ export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/lampp/lib/ </span>
问题四:PIL IOError: cannot identify image file 'images/1212.jpg'的解决办法
from PIL import Image
instead of
import Image
fixed the issue
最后,贴上我的测试和结果:
aa.py:
#!/usr/bin/env python # -*- coding:utf-8 -*- #import Image #import ImageFont from PIL import Image picPath = 'images/1212.jpg' im = Image.open(picPath) print im.getbbox()
结果:
(0, 0, 451, 182)
相关文章推荐
- PIL IOError: cannot identify image file 'images/1212.jpg'的解决办法
- python IOError: cannot identify image file
- python IOError: cannot identify image file
- scrapy爬虫之错误 No module named PIL + IOError:decoder jpeg not available +PIL的安装
- docker 安装PIL python 报错 IOError: decoder zip not available
- Python代码调试问题:IOError: cannot identify image file
- python PIL IOError: decoder jpeg not available
- Python PIL : IOError: decoder jpeg not available
- PIL IOError: decoder jpeg not available
- PIL不能正常使用exceptions.IOError: decoder jpeg not available
- 修正pil错误 IOError: decoder zip not available
- python解决osx安装PIL时的_imagingft.c:73:10: fatal error: 'freetype/fterrors.h' file not found
- ImportError: No module named Image IOError: decoder zip not available
- PIL image 提示 decoder jpeg not available
- win7用easybcd从硬盘安装ubuntu 11.10重启出现error 15 file not found错误
- Hadoop error:File does not exist: /benchmarks/TestDFSIO/io_data/test_io_0
- PHP 5.2.14安装 configure: error: DBA: Could not find necessary header file(s).
- Cannot access the ClassView information file.ClassView information will not be available
- jni error: cannot access class file for not found javadoc:error
- 安装rvds2.2,出现Error: %variable HOSTPLAT is not defined in File RDI\armsd\1.3.1\66\install.xml