ubuntu12.04.4下安装python模块PIL
2014-03-30 15:00
495 查看
1. 问题描述:运行python文件出现以下信息:
from PIL import ImageTk, Image ImportError: No module named PIL
2. 解决方法:
(1) 安装python-imaging-tk
sudo apt-get install python-imaging-tk
(2) 安装Python Imaging Library(PIL):
PIL下载地址:http://www.pythonware.com/products/pil/
我目前下载的是Python Imaging Library 1.1.7 Source Kit, 包包名为 Imaging-1.1.7.tar.gz
解压:
tar -xzvf Imaging-1.1.7.tar.gz
切换到管理员命令行(ps:这里说明下, 为什么要切换到管理员身份呢? 因为安装的时候要创建文件夹, 而普通用户身份是无法做到的, 如果不信你试下普通用户身份安装就知道了):
sudo -s
以管理员身份安装:
python setup.py build
由上面可知JPEG、ZLIB、FREETYPE2、LITTLECMS还没安装, TKINTER库已安装.
Tkinter安装参照:/article/8659013.html
JPEG、ZLIB、FREETYPE2、LITTLECMS安装参照:/article/8659015.html
安装完 TKINTER、 JPEG、 ZLIB、FREETYPE2、LITTLECMS后, 再次检测:
python setup.py build
检测模块是否可用:
python setup.py build_ext -i
信息如下:
cryhelyxx@ada:~/下载/Imaging-1.1.7$ python setup.py build_ext -i running build_ext -------------------------------------------------------------------- PIL 1.1.7 SETUP SUMMARY -------------------------------------------------------------------- version 1.1.7 platform linux2 2.7.6 (default, Mar 30 2014, 00:48:22) [GCC 4.6.3] -------------------------------------------------------------------- --- 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 required library, and set the corresponding ROOT variable in the setup.py script. To check the build, run the selftest.py script.
测试模块:
python selftest.py
信息如下:
cryhelyxx@ada:~/下载/Imaging-1.1.7$ python selftest.py -------------------------------------------------------------------- PIL 1.1.7 TEST SUMMARY -------------------------------------------------------------------- Python modules loaded from ./PIL Binary modules loaded from ./PIL -------------------------------------------------------------------- --- PIL CORE support ok --- TKINTER support ok *** JPEG support not installed *** ZLIB (PNG/ZIP) support not installed --- FREETYPE2 support ok *** LITTLECMS support not installed -------------------------------------------------------------------- Running selftest: ***************************************************************** Failure in example: try: _info(Image.open(os.path.join(ROOT, "Images/lena.jpg"))) except IOError, v: print v from line #24 of selftest.testimage Expected: ('JPEG', 'RGB', (128, 128)) Got: decoder jpeg not available 1 items had failures: 1 of 57 in selftest.testimage ***Test Failed*** 1 failures. *** 1 tests of 57 failed. cryhelyxx@ada:~/下载/Imaging-1.1.7$
显而易见, TKINTER、JPEG、 ZLIB、FREETYPE2都可用, LITTLECMS不可用, 但JPEG、ZLIB、LITTLECMS还是未成功安装, 有待研究...。
继续安装PIL:
python setup.py install
3. 检验是否成功安装python模块PIL:
终端输入:
python
from PIL import ImageTk, Image
如下:
4. OK, 没消息就是好消息, 恭喜你已成功安装python模块PIL...Enjoy it!!!
相关文章推荐
- ubuntu12.04.4下安装python模块gevent
- Ubuntu环境下完美安装python模块numpy,scipy,matplotlib
- 一、基本模块python,Numpy, PIL, Opencv的安装(computer vision with python)
- Ubuntu 安装 Python 模块MySQLdb
- ubuntu12.04.4下安装python的4个库JPEG、 ZLIB、 FREETYPE2和 LITTLECMS
- 及时记录--ubuntu安装python3模块
- centos 安装python PIL模块
- Windows安装Python图像处理库:PIL模块
- windows 64位安装Python以及PIL模块详细步骤
- centos 安装python PIL模块
- python PIL模块安装
- ubuntu12.04.4下安装python2.7.6
- python模块 mysql-python安装(在ubuntu系统下)
- Linux 安装Python/PIL模块
- ubuntu下mysql-python模块的安装
- ubuntu下python安装第三方模块
- centos 安装python PIL(Python Imaging Library)模块
- 【转】Windows安装Python图像处理库:PIL模块
- Ubuntu下给Python2安装PIL(Python_Image_Library)
- mac下python安装pil模块缺少stdio.h的错误