ubuntu12.04.4下安装python模块PIL
来源:互联网 发布:sql select as 编辑:程序博客网 时间:2024/05/22 10:05
1. 问题描述:运行python文件出现以下信息:
from PIL import ImageTk, ImageImportError: 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安装参照:http://blog.csdn.net/cryhelyxx/article/details/22514871
JPEG、ZLIB、FREETYPE2、LITTLECMS安装参照:http://blog.csdn.net/cryhelyxx/article/details/22589707
安装完 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 -irunning build_ext--------------------------------------------------------------------PIL 1.1.7 SETUP SUMMARY--------------------------------------------------------------------version 1.1.7platform 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 requiredlibrary, and set the corresponding ROOT variable in thesetup.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 ./PILBinary 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 vfrom line #24 of selftest.testimageExpected: ('JPEG', 'RGB', (128, 128))Got: decoder jpeg not available1 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!!!
0 0
- ubuntu12.04.4下安装python模块PIL
- ubuntu12.04.4下安装python模块gevent
- python 安装PIL模块
- Linux 安装Python/PIL模块
- centos 安装python PIL模块
- centos 安装python PIL模块
- 64位centos下安装python的PIL模块
- Mac 下安装python PIL
- Linux系统安装Python PIL模块
- centos 安装python的PIL matplotlib模块
- mac下python安装pil模块缺少stdio.h的错误
- ubuntu12.04.4下安装python-pygame
- Python PIL模块整理
- win64 Python下安装PIL出错解决
- linux下安装python图像库PIL
- win64下python安装PIL出错
- python windows 下安装 PIL 库
- win64 Python下安装PIL出错解决
- 对不起,我爱你黄陈晨
- Android 中Touch(触屏)事件传递机制
- WEB:建立短链接服务
- 跳跃链表
- cocos2d-x在eclipse上搭建开发环境(全网最标准方法,不要cywin)
- ubuntu12.04.4下安装python模块PIL
- C++: byte和int的相互转化
- PHP之 开始篇
- php中的sprintf(),printf()
- 斯坦福机器学习-week5 学习笔记(1)——神经网络训练BP算法与Gradient checking
- Android使用https链接
- SQL技巧--------查询重复
- opencv 实践程序2——背景差分法实现前景识别
- 来自苹果、谷歌、微软等知名公司六道有趣智力面试题,试试吧!