今天帮朋友做个python的小工具,发现系统上缺少ptyhon的支持库,返回如下信息
importerror: no module named pil
然后就下载安装,因为机器上也没有python的管理工具pip,所以也一并安装
1. 安装pip
sudo easy_install pip
pip 安装成功就可以直接安装pil或者pillow
2. 通过命令pip install pil
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
pip install –use-wheel pillow
downloading/unpacking pillow
downloading pillow-2.4.0.zip (6.5mb): 5.0mb downloaded
cleaning up…
弄了会别的回来发现还没有下载完,这叫一个慢呀,于是放弃
4. git
通过git下载源码地址https://github.com/python-imaging/pillow
git clone https://github.com/python-imaging/pillow.git
然后开始编译安装
4.1
python setup.py build_ext -i
编译完之后会提示运行测试例子,并且发现jpeg support not available
——————————————————————–
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报告错误
1 tests of 57 failed.
于是只好卸载pillow
可以通过pip命令来卸载
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的支持
brew install libjpeg
安装成功之后重新编译pillow
——————————————————————–
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
——————————————————————–
python selftest.py
——————————————————————–
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.
最后执行安装
sudo python setup.py install