[Python]ubuntu 12.04下面安裝影像處理的庫PIL的安裝, Pygame的安裝,以及一些實用的資料整理

轉載
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/

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容