安装Pillow及报错的3种解决方法
大家好!我是老码农。
《码农说》公众号的第16篇文章来袭。
今天分享的主题:如何安装Pillow及报错的3种解决方法。
看到很多同学安装时Pillow会遇到些问题。
我做了一个梳理,希望对大家能有帮助。
官网
-
https://pillow.readthedocs.io/en/latest/installation.html
-
- https://pillow-zh-cn.readthedocs.io/zh-cn/latest/index.html
-
- https://github.com/python-pillow/Pillow
-
- https://pillow-zh-cn.readthedocs.io/zh-cn/latest/installation.html
详细记述了安装的注意事项
-
- https://pillow-zh-cn.readthedocs.io/zh-cn/latest/handbook/index.html
详细介绍如何使用Pillow
安装
我使用的是conda
包管理器进行的安装,还是比较顺利的,一次成功。
我之前在oldgeek
环境里,安装过jupyterlab
和pandas
等包,估计当时就把Pillow
给安装上了。
(oldgeek) C:\oldgeek>conda install -y Pillow
Retrieving notices: ...working... done
Channels:
- defaults
- conda-forge
Platform: win-64
Collecting package metadata (repodata.json): done
Solving environment: done
# All requested packages already installed.
(oldgeek) C:\oldgeek>
如果遇到问题
第1种方案:尝试用conda
安装
conda install -y Pillow
第2种方案
参照官网的安装指引,指引地址
- https://pillow-zh-cn.readthedocs.io/zh-cn/latest/installation.html
官方指引上有明确记载,注意Python的版本和Pillow的版本
警告
Pillow 和 PIL 不能同时存在. 请务必在安装Pillow之前卸载PIL.
警告
Pillow >= 1.0 的版本不再支持 “import Image”. 请使用 “from PIL import Image” 来代替之.
警告
Pillow >= 2.1.0 的版本不再支持 “import _imaging”. 请使用 “from PIL.Image import core as _imaging” 来代替之.
注解
注解
Pillow < 2.0.0 支持这些 Python 版本: 2.4, 2.5, 2.6, 2.7.
注解
Pillow >= 2.0.0 支持这些 Python 版本: 2.6, 2.7, 3.2, 3.3, 3.4, 3.5
如果用pip
安装的话,可以尝试
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow
官方这里有详细的关于版本对照的记述
- https://pillow.readthedocs.io/en/latest/installation.html
Python | 3.12 | 3.11 | 3.10 | 3.9 | 3.8 | 3.7 | 3.6 | 3.5 |
---|---|---|---|---|---|---|---|---|
Pillow >= 10.1 | Yes | Yes | Yes | Yes | Yes | |||
Pillow 10.0 | Yes | Yes | Yes | Yes | ||||
Pillow 9.3 - 9.5 | Yes | Yes | Yes | Yes | Yes | |||
Pillow 9.0 - 9.2 | Yes | Yes | Yes | Yes | ||||
Pillow 8.3.2 - 8.4 | Yes | Yes | Yes | Yes | Yes | |||
Pillow 8.0 - 8.3.1 | Yes | Yes | Yes | Yes | ||||
Pillow 7.0 - 7.2 | Yes | Yes | Yes | Yes |
第3种方式
大家可以参照下这篇文章的第二种方法, 下载指定版本的,然后安装
- python安装pillow的三种方法
- https://www.jb51.net/article/229964.htm
码农说
好的!今天就聊到这里!点个关注呗!创作不易,大家的支持就是我坚持下去的原动力!
这是咱们程序员的家,一起分享最好的工具、最优质的资源、最干的文章,闲来无事唠唠职场。