PIL 的官方版本,但是最后一次维护是2009年,现以宣布停止维护,可以运行在python2.7上。
Pillow PIL 的fork版本,还在继续维护更新,建议安装 Pillow 。
在安装Pillow之前,请卸载PIL
安装Pillow 依赖,下面安装是真对ubuntu14.04版本
下面介绍各包提供功能,以及需要的包版本限制(重要)
在我的 ubuntu14.04 中缓春友 openjpeg 版本过低,所以找到 openjpeg 的官森扮方网站编译安装最新版的 openjpeg
完成依赖安装后,使用命令 sudo pip install Pillow 安装Pillow
在我的ubuntu 14.04安扰槐装成功后,在导入仍然提示: [PIL - libopenjp2.so: cannot open shared object file: No such file or directory] 这样的错误,在stackoverflow找到了解决方法:
1. 安装pip[plain] view plain copy
sudo easy_install pip
pip 安装成功就可以直接安装pil或者pillow
2. 通过命令pip install pil
[plain] view plain copy
pip install Pil
Downloading/unpacking Pil
Could not find any downloads that satisfy the requirement Pil
Some externally hosted files were ignored (use --allow-external Pil to allow).
Cleaning up...
No distributions at all found for Pil
Storing debug log for failure in /Users/macbook/Library/Logs/pip.log
3. 所以就安装pillow
[plain] view plain copy
pip install --use-wheel Pillow
Downloading/unpacking Pillow
Downloading Pillow-2.4.0.zip (6.5MB): 5.0MB downloaded
Cleaning up...
弄了会别的回来发现还没有下载完,这叫一个慢呀,于是放弃
4. 通过Git下载源首纯码地址https://github.com/python-imaging/Pillow
[plain] view plain copy
git clone https://github.com/python-imaging/Pillow.git
然后开始编译安锋腔装银芹衫
4.1
[plain] view plain copy
python setup.py build_ext -i
编译完之后会提示运行测试例子,并且发现JPEG support not available
[plain] view plain copy
--------------------------------------------------------------------
version Pillow 2.4.0
platform darwin 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
--------------------------------------------------------------------
--- TKINTER support available
*** JPEG support not available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBTIFF support not available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX 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.
4.2 因为JPEG support not available,运行python selftest.py报告错误
[plain] view plain copy
1 tests of 57 failed.
于是只好卸载pillow
可以通过pip命令来卸载
[plain] view plain copy
pip uninstall pillow
sudo pip uninstall pillow
Password:
Uninstalling Pillow:
/Library/Python/2.7/site-packages/Pillow-2.4.0-py2.7-macosx-10.9-intel.egg
/usr/local/bin/pilconvert.py
/usr/local/bin/pildriver.py
/usr/local/bin/pilfile.py
/usr/local/bin/pilfont.py
/usr/local/bin/pilprint.py
Proceed (y/n)? y
Successfully uninstalled Pillow
成功之后需要安装libjpeg的支持
[plain] view plain copy
brew install libjpeg
安装成功之后重新编译pillow
[plain] view plain copy
--------------------------------------------------------------------
version Pillow 2.4.0
platform darwin 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
*** OPENJPEG (JPEG2000) support not available
--- ZLIB (PNG/ZIP) support available
*** LIBTIFF support not available
--- FREETYPE2 support available
*** LITTLECMS2 support not available
*** WEBP support not available
*** WEBPMUX support not available
--------------------------------------------------------------------
[plain] view plain copy
python selftest.py
[plain] view plain copy
--------------------------------------------------------------------
Pillow 2.4.0 TEST SUMMARY
--------------------------------------------------------------------
Python modules loaded from /Users/macbook/yyang/app-devel-source/python/Pillow/PIL
Binary modules loaded from /Users/macbook/yyang/app-devel-source/python/Pillow/PIL
--------------------------------------------------------------------
--- PIL CORE support ok
--- TKINTER support ok
--- JPEG support ok
*** JPEG 2000 support not installed
--- ZLIB (PNG/ZIP) support ok
*** LIBTIFF support not installed
--- FREETYPE2 support ok
*** LITTLECMS2 support not installed
*** WEBP support not installed
--------------------------------------------------------------------
Running selftest:
--- 57 tests passed.
最后执行安装
[plain] view plain copy
sudo python setup.py install
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)