在Mac OS系统上安装Python的Pillow库的教程
作者:bulreed 发布时间:2021-09-29 15:03:26
标签:Pillow
今天帮朋友做个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


猜你喜欢
- 一、为何人工智能(AI)首选Python?读完这篇文章你就知道了。我们看谷歌的TensorFlow基本上所有的代码都是C++和Python,
- 现象:已知,连接的WIFI网络需要通过代理服务器才能连接外网,按照正常的程序无法发送邮件,而直连一个没有代理的网络【如自己的wifi热点】,
- 一、什么是索引 减少磁盘I/O和逻辑读次数的最佳方法之一就是使用【索引】 索引允许SQL Server在表中查找数据而不需要扫描整个表。 1
- 非聚集索引,这个是大家都非常熟悉的一个东西,有时候我们由于业务原因,sql写的非常复杂,需要join很多张表,然后就泪流满面了。。。这时候就
- SQL Server数据库查询速度慢的原因有很多,常见的有以下几种:1、没有索引或者没有用到索引(这是查询慢最常见的问题,是程序设计的缺陷)
- 安装部分所需文件在最下方提供STEP1双击mysql-installer-web-community-8.0.18.0.msi进行按钮如果出
- 最近仿写一个项目,如下目录,base内部都是一些基础的组件,但是并没有在main.js 中使用常规的方式去全局注册的,刚开始还不明白没有注册
- function commafyback(num) { var x = num.split(','); return par
- 前言matplotlib是Python中的一个第三方库。主要用于开发2D图表,以渐进式、交互式的方式实现数据可视化,可以更直观的呈现数据,使
- 本文主要研究的是python读取jpg格式图片并显示为16进制的相关内容,具体如下。代码:>>> aaa = open(&
- 目录目标为什么操作步骤工程截图运行效果目标在SpringBoot中集成内存数据库Derby.为什么像H2、hsqldb、derby、sqli
- 前言: 上一篇讲了Python排序问题中比较经典的三个方法,(链接:关于Python排
- 小编最经常的工作是将一些项目的数据从数据库导出,然后分门别类的列到excel表格中,领导看起来眼花缭乱。小编想,要是能以图表可视化展现出来,
- Numpy是Python强大的数据计算和处理模块,其操作数据非常迅速且简单易行。首先读取CSV文件>>> import n
- 比如有下面一段代码: for i in range(10): print ("%s" % (f_list[i].name
- plt.plot()函数各参数解析plt.plot()函数的作用是绘制折线图,它的参数有很多,常用的函数参数如下:plt.plot(x,y,
- MySQL 5.7.9版本sql_mode=only_full_group_by问题用到GROUP BY 语句查询时com.MySQL.jd
- Python 文件操作的详解及实例一、文件操作1、对文件操作流程打开文件,得到文件句柄并赋值给一个变量通过句柄对文件进行操作关闭文件现有文件
- 1. 下载可以去清华源下载最新版的anaconda包,这比在官方网站下载快得多,地址如下:https://mirrors.tuna.tsin
- 当然有,看看下面,你就会明白:<%Sub TimeDelaySeconds(Delay