问题描述
尝试时出现错误
from PIL import Image, ImageFilter
在Python文件中,出现错误,提示ModuleNotFoundError: No module named 'PIL'
.
in a Python file I get an error stating ModuleNotFoundError: No module named 'PIL'
.
到目前为止,我只是尝试import Image
尝试卸载/重新安装PIL和Pillow,但是错误一直在发生,我也不知道为什么.到目前为止,我发现的所有解决方案都对我的问题没有影响.
So far I've tried uninstalling/reinstalling both PIL and Pillow, along with just doing import Image
, but the error keeps on occurring and I have no idea why. All the solutions I've found so far have had no effect on my issue.
我正在Ubuntu 16.04上运行Python 3.5
I'm running Python 3.5 on Ubuntu 16.04
推荐答案
好的,我找到了解决方法
Alright, I found a fix
为解决此问题,我通过sudo pip3 uninstall pillow
和sudo apt-get purge python3-pil
卸载了PIL
和Pillow
.然后,我重新启动,然后使用sudo -H pip3 install pillow
重新安装Pillow
To fix the issue, I uninstalled PIL
and Pillow
through sudo pip3 uninstall pillow
and sudo apt-get purge python3-pil
. I then restarted and then used sudo -H pip3 install pillow
to reinstall Pillow
我之前唯一缺少的步骤是重新启动,然后不重新安装PIL
.
The only step I was missing before was rebooting, and not reinstalling PIL
afterwards.
到目前为止,它似乎没有任何问题.
It seems to have worked without any issues so far.
这篇关于没有名为"PIL"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!