python3.9没有自带图形处理库
需要安装库Pillow
pip install Pillow
才能使用以下命令
from PIL import Image
系统里面有几个版本的python
默认设定指令python 为2.7 python3 为3.9
升级指定版本
第一步升级pip
pip经常升级的
python3 -m pip install --upgrade pip
使用pip安装库
python2 -m pip install ***
python3 -m pip install ***
默认不用国内源安装pillow
python3 -m pip install pillow
使用国内源安装pillow
python3 -m pip install pillow -i https://pypi.tuna.tsinghua.edu.cn/simple/
国内源选择
(1)阿里云 http://mirrors.aliyun.com/pypi/simple/
(2)豆瓣http://pypi.douban.com/simple/
(3)清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
(4)中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
(5)华中科技大学http://pypi.hustunique.com/
查看安装列表
默认python
pip list
指定python版本查看
python3 -m pip list
至目前 Pillow版本
Pillow 8.1.2
刚开始,我也以为有PIL这个库的
结果发现没有的
下面的是错误示例
[dalaojun@localhost python语言程序设计13期]$ python3 -m pip install PIL
Defaulting to user installation because normal site-packages is not writeable
ERROR: Could not find a version that satisfies the requirement PIL
ERROR: No matching distribution found for PIL