在使用TensorFlow处理图片文件时,需要用到图像读取库:from pillow import Image,但这时候执行会报错,ModuleNotFoundError: No module named 'pillow'
缺少PIL模块,但是我觉得Anaconda应该都包含这些模块了吧,好吧,还是重装一下试试吧。
去pillow官网看一下http://pythonware.com/products/pil/
发现PIL的安装最多只支持到Python 2.7,而支持TensorFlow的Python版本只能在Python 3.5以上。呵呵……
解决方案:可以使用pillow来代替:Pillow is the friendly PIL fork by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lundh and Contributors.
那就安装pillow吧,可以使用pip命令安装:pip install Pillow,安装完成后使用pip list查看已经安装的模块即可。(如果pip版本较低,可能会出现安装错误,不过使用pip指令时会提醒你进行升级:python -m pip install --upgrade pip)
我采用的方法是直接界面式的,打开Anaconda的Anaconda Navigator,进入Environment——>tensorflow——>Not installed,搜索pillow,选中前面的框框,安装即可。
下图是我安装成功后的状态:
如果安装过程中报错CondaHTTPError: HTTP 000 CONNECTION FAILED for url……,请参考博客:https://blog.csdn.net/wumenglu1018/article/details/87954885