想生成个图片验证码,使用的PIL,怎么都下载不下来,说是PIL被取代了,改成Pillow,好吧,继续安装这个,我是centos7上安装,python2.7.5。
附上官网的各种安装方式:
https://pillow.readthedocs.io/en/latest/installation.html#python-support
captcha这个库生成验证码很方便,但是也依赖PIL,要使用的可以看下
|
Python
|
3.10
|
3.9
|
3.8
|
3.7
|
3.6
|
3.5
|
3.4
|
2.7
|
|
Pillow >= 8.4
|
Yes
|
Yes
|
Yes
|
Yes
|
Yes
|
|
|
|
|
Pillow 8.0 - 8.3
|
|
Yes
|
Yes
|
Yes
|
Yes
|
|
|
|
|
Pillow 7.0 - 7.2
|
|
|
Yes
|
Yes
|
Yes
|
Yes
|
|
|
|
Pillow 6.2.1 - 6.2.2
|
|
|
Yes
|
Yes
|
Yes
|
Yes
|
|
Yes
|
|
Pillow 6.0 - 6.2.0
|
|
|
|
Yes
|
Yes
|
Yes
|
|
Yes
|
|
Pillow 5.2 - 5.4
|
|
|
|
Yes
|
Yes
|
Yes
|
Yes
|
Yes
|
|
Python
|
3.6
|
3.5
|
3.4
|
3.3
|
3.2
|
2.7
|
2.6
|
2.5
|
2.4
|
|
Pillow 5.0 - 5.1
|
Yes
|
Yes
|
Yes
|
|
|
Yes
|
|
|
|
|
Pillow 4
|
Yes
|
Yes
|
Yes
|
Yes
|
|
Yes
|
|
|
|
|
Pillow 2 - 3
|
|
Yes
|
Yes
|
Yes
|
Yes
|
Yes
|
Yes
|
|
|
|
Pillow < 2
|
|
|
|
|
|
Yes
|
Yes
|
Yes
|
Yes
|
Requirement already satisfied (use --upgrade to upgrade): pillow in /opt/nsfocus/espc/deps/env/lib/python2.7/site-packages
/opt/nsfocus/espc/deps/env/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.
SNIMissingWarning
/opt/nsfocus/espc/deps/env/lib/python2.7/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
解决方案:
搜了好久,各种回答都有,下面这个方法解决了,使用豆瓣源http,跳过ssl验证
pip install -i http://pypi.douban.com/simple pillow==6.2.0 --trusted-host pypi.douban.com
最近在学习Django,在model中用到了ImageField,然后系统提示需要
Pillow
模块。想着这个很简单,就使用了常规命令:
pip
install
Pillow
安装
,结果
报错
。后来又在Pypi网站上下载
Pillow
模块,进行线下
安装
,仍旧
报错
。
使用Pycham
安装
Pillow
还是
报错
,具体
报错
信息如下:
(leighblogvenv) D:\zhangli\leighblog&...
@
安装
Python
模块超时
问题
Python
3以上的版本要使用PIL库就要
安装
pillow
,假如你最开始没有改变下载路径的话,在DOC窗口直接输入
pip
install
pillow
,使用的是国外的下载源,会出现超时
问题
,所以我们使用国内的pypi源即可
解决
超时
问题
(在结尾加上-i+下载网址路径即可)。
执行以下操作即可正确
安装
。
以下是国内pypi源
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.ed
使用conda进行
安装
:如果你正在使用Anaconda或Miniconda等
Python
发行版,可以尝试使用conda来
安装
Pillow
库。使用国内的镜像源进行
安装
:可以使用清华大学开源软件镜像站或者阿里云镜像源来加速
安装
。在使用
pip
安装
时,可以添加。警告提示表明在
安装
Pillow
库时遇到了SSL连接错误。升级
pip
:确保你正在使用最新版本的
pip
。通过尝试以上方法,希望你能够成功
解决
安装
Pillow
库时的SSL连接
问题
。这样使用镜像源可能会避免由于网络原因导致的连接
问题
。
一开始我是自己打开命令行,直接输入
pip
install
pillow
,结果运行代码时
报错
:
ModuleNotFoundError: No module named 'PIL'
在
安装
过程中,还报过这样的错误:Requirement already satisfied:
pillow
in c:\
python
\lib\site-packages (9.0.1)
后来我卸载了一次,按照下面步骤
安装
成功了。
在命令行窗口打开
python
所在的目录,我是在C盘下
1.
pillow
库的基本概述
pillow
(有时也称 PIL 库) 是
Python
图像处理的基础库,它是一个免费开源的第三方库,由一群
Python
社区志愿者使用
Python
语言开发而成,如果要使用需要下载。2..
pillow
库的
安装
2.1IDLE
安装
pillow
按下win+r打开运行窗口,在窗口输入cmd然后按下回车后就打开cmd(命令提示符)了在cmd中输入如果
安装
不成功可以输入以下代码查看
pip
版本
pip
版本较低的话可以先输入下面的代码升级版本
pip
。
Python
中
安装
pillow
一直
报错
解决
直接用
pip
install
pillow
按装
报错
,尝试用以下命令(先找到
python
的site-packages的位置):
pip
install
--target=D:\
python
\Lib\site-packages
pillow