• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >python > 在Mac OS系统上安装Python的Pillow库的教程

在Mac OS系统上安装Python的Pillow库的教程

作者: 字体:[增加 减小] 来源:互联网

通过本文主要向大家介绍了mac pillow talk,python3 pillow,python pillow,python3.5 pillow,python pillow下载等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

今天帮朋友做个python的小工具,发现系统上缺少ptyhon的支持库,返回如下信息

ImportError: No module named PIL 
然后就下载安装,因为机器上也没有python的管理工具pip,所以也一并安装
1. 安装pip

sudo easy_install pip 
</div>

pip 安装成功就可以直接安装pil或者pillow


2. 通过命令pip install pil

pip install Pil 
</div>
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 
</div>

3. 所以就安装pillow

pip install --use-wheel Pillow 
</div>
Downloading/unpacking Pillow 
 Downloading Pillow-2.4.0.zip (6.5MB): 5.0MB downloaded 
Cleaning up... 
</div>

弄了会别的回来发现还没有下载完,这叫一个慢呀,于是放弃
4. Git

通过git下载源码地址https://github.com/python-imaging/Pillow

git clone https://github.com/python-imaging/Pillow.git 
</div>

然后开始编译安装

4.1

python setup.py build_ext -i 
</div>

编译完之后会提示运行测试例子,并且发现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. 

</div>

4.2 因为JPEG support not available,运行python selftest.py报告错误


1 tests of 57 failed. 

于是只好卸载pillow

可以通过pip命令来卸载

pip uninstall pillow 
sudo pip uninstall pillow 
</div>
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 
</div>

成功之后需要安装libjpeg的支持

brew install libjpeg 
</div>

安装成功之后重新编译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. 

</div>

最后执行安装

sudo python setup.py install 
</div>

</div>

您可能想查找下面的文章:

  • 在Mac OS系统上安装Python的Pillow库的教程

相关文章

  • Python中的ctime()方法使用教程
  • 有关wxpython pyqt内存占用问题分析
  • Python中的if、else、elif语句用法简明讲解
  • Python文件操作类操作实例详解
  • python发送邮件示例(支持中文邮件标题)
  • python使用PyV8执行javascript代码示例分享
  • python连接mongodb操作数据示例(mongodb数据库配置类)
  • python中cPickle用法例子分享
  • python实现查找两个字符串中相同字符并输出的方法
  • python二分查找算法的递归实现方法

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • python使用PIL缩放网络图片并保存的方法
    • Python实现全角半角转换的方法
    • python实现简单的计时器功能函数
    • Python中Collection的使用小技巧
    • python基于pyDes库实现des加密的方法
    • python paramiko实现ssh远程访问的方法
    • Ubuntu下安装PyV8
    • Python程序设计入门(2)变量类型简介
    • python使用正则表达式匹配字符串开头并打印示例
    • 在Python上基于Markov链生成伪随机文本的教程

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有