在Mac OS系统上安装Python的Pillow库的教程
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
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
相关文章
相关视频
专题推荐
-
独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
-
玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
-
天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
上一篇: 关于php headers_list()的文章推荐
下一篇: C# 性能优化最佳实践
推荐阅读
-
在Mac OS上搭建Python的开发环境
-
在Linux系统上通过uWSGI配置Nginx+Python环境的教程
-
在Windows系统上搭建Nginx+Python+MySQL环境的教程
-
在树莓派2或树莓派B+上安装Python和OpenCV的教程
-
在Linux上安装Python的Flask框架和创建第一个app实例的教程
-
在Linux系统上安装数据库监控程序Bugzilla的方法
-
在Linux系统上安装VPN服务器的教程
-
在Mac 上制作OS X 10.10 Yosemite U盘的图文教程
-
在Linux系统上安装Linux内核头文件的教程
-
python库lxml在linux和WIN系统下的安装
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论