[Python]ubuntu 12.04下面安装影像处理的库PIL的安装, Pygame的安装,以及一些实用的资料整理
admin
2023-07-30 20:31:24
0

转载
1.Install PIL

$ sudo apt-get install python-imaging
$ sudo apt-get install libjpeg-dev libfreetype6 libfreetype6-dev zlib1g-dev

然后:

$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
$ sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/

最后:

$ pip install PIL

一般这样就可以了。完成!^^

但是如果出现:

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -IlibImaging -I/usr/include -I/usr/local/include -I/usr/include/python2.6 -c _imaging.c -o build/temp.linux-i686-2.6/_imaging.o
_imaging.c:75:20: error: Python.h: 没有那个文件或目录
In file included from libImaging/Imaging.h:14,from _imaging.c:77:

错误信息,最后的显示结果为: command \’gcc\’ failed with exit status 1

就还需要做下面的事情。

1.安装python-all-dev

2.然后执行PIL文件下的setup.py

参见此君的博文:

http://blog.sina.com.cn/s/blog_5cd78a5d0101jcza.html

为了找到缺什么,我们运行 apt-cache search python | grep devh 没有找到python的C语言开发包。 安装python-all-dev,于是然后执行PIL文件下的setup.py,安装成功。

Pygame的安装

如果输入

$ pip intsall Pygame 

会出现下面的错误

No such file or directory: \'/home/×××××/build/Pygame/setup.py\'

使用就可以

$ pip install http://www.pygame.org/ftp/pygame-1.9.1release.tar.gz

可以详细看关于这个Bug的issue讨论:https://bitbucket.org/pygame/pygame/issue/59/pygame-has-no-pypi-page-and-cant-be
2.有用的参考资料:

官方文档 http://effbot.org/imagingbook/
数字图像处理PIL的一个实例 http://blog.sina.com.cn/s/blog_4b5039210100f6ki.html
一篇关于如何成为Python高手的文章,是从 How to become a proficient Python programmer 这篇文章翻译而来的 http://www.zhizhihu.com/html/y2011/3093.html
把图片的数据变换成数组 http://blog.csdn.net/zhengkarl/article/details/5731317
Python图形图像处理库的介绍之Image模块 http://tojaoomy.iteye.com/blog/1413810
微博关键字图片生成算法 http://ued.ctrip.com/blog/?p=2471
Matplotlib的官方文档 http://matplotlib.sourceforge.net/Matplotlib.pdf

3.References:

http://askubuntu.com/questions/156484/how-do-i-install-python-imaging-library-pil
http://www.sandersnewmedia.com/why/2012/04/16/installing-pil-virtualenv-ubuntu-1204-precise-pangolin/
http://blog.sina.com.cn/s/blog_5cd78a5d0101jcza.html

benwen
http://www.wildflame.org/how_to_install_PIL_for_python_under_ubuntu_12.04/

相关内容

热门资讯

Mobi、epub格式电子书如... 在wps里全局设置里有一个文件关联,打开,勾选电子书文件选项就可以了。
500 行 Python 代码... 语法分析器描述了一个句子的语法结构,用来帮助其他的应用进行推理。自然语言引入了很多意外的歧义,以我们...
定时清理删除C:\Progra... C:\Program Files (x86)下面很多scoped_dir开头的文件夹 写个批处理 定...
scoped_dir32_70... 一台虚拟机C盘总是莫名奇妙的空间用完,导致很多软件没法再运行。经过仔细检查发现是C:\Program...
65536是2的几次方 计算2... 65536是2的16次方:65536=2⁶ 65536是256的2次方:65536=256 6553...
小程序支付时提示:appid和... [Q]小程序支付时提示:appid和mch_id不匹配 [A]小程序和微信支付没有进行关联,访问“小...
pycparser 是一个用... `pycparser` 是一个用 Python 编写的 C 语言解析器。它可以用来解析 C 代码并构...
微信小程序使用slider实现... 众所周知哈,微信小程序里面的音频播放是没有进度条的,但最近有个项目呢,客户要求音频要有进度条控制,所...
Apache Doris 2.... 亲爱的社区小伙伴们,我们很高兴地向大家宣布,Apache Doris 2.0.0 版本已于...
python清除字符串里非数字... 本文实例讲述了python清除字符串里非数字字符的方法。分享给大家供大家参考。具体如下: impor...