Pycharm 报错“NameError: name ’ Image’is not defined”
##When running the code today, the following error occurred:
According to the search, it can be installed directly on the anaconda prompt:
pip install Pillow
pip insall image
Or search directly in pycharm
, but I can search for pillow, but not for image. And pip install image reports an error:
Notice! ! ! Turn off the VPN! ! ! Install again! !
pip install Pillow from PIL import Image
###Some bloggers provided the following methods: But I tried them all, but the result was not satisfactory, and I still reported an error! !
Douban Mirror Site
pip install Pillow from PIL import Image -i http://pypi.doubanio.com/simple/ --trusted-host pypi.doubanio.com
Tsinghua University:
pip install Pillow from PIL import Image -i https://pypi.tuna.tsinghua.edu.cn/simple/ --trusted-host pypi.tuna.tsinghua.edu.cn
Douban:
pip install Pillow from PIL import Image -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
at last! ! ! The input pip install image
was successful!
but! I opened Pycharm again and still reported an error, still:
I found a very magical thing at this time, the library displayed in Pycharm and Anaconda is actually different, the image library exists in Anaconda, but does not exist in Pycharm! Look at the picture:
I went back to see the import statement and found:
from PIL import Image as pil_image
So
change to:
Finally you're done, and it took a long time to go around, hey!