python程序执行from PIL import Image, ImageDraw, ImageFont, ImageFilter 报错,显示 no PIL module
解决方案:
1. import PIL package(失败)
结果:显示安装失败,图片如下
按照提示,原因可能是pip版本,所以 执行 /usr/local/bin/python3.7 -m pip install --upgrade pip,更新pip
再次安装PIL包,依旧不能成功安装。
2. Setting里面搜索PIL ,安装(失败)
结果:和第一步安装报相同错误
3.terminal 执行(失败)
pip3 install PIL
结果:报错如下:
4.安装Pillow(成功解决)
经过搜索发现,
python 现在已经用pillow替代PIL了,因为PIL最多支持的python版本是2.7, 而pillow 版本大于2.1支持python2.6,2.7以及3.x, 我用的是python3.7
解决方案:
import Pallow 或在 setting里安装Pillow 包 即可正常导入,问题解决