python中的image.load\u img错误,Keras

python中的image.load\u img错误,Keras,python,python-3.x,keras,anaconda,pillow,Python,Python 3.x,Keras,Anaconda,Pillow,我有以下代码 from keras.preprocessing import image test_image = image.load_img('roi.jpg', target_size = (64, 64),grayscale=True) test_image = image.img_to_array(test_image) test_image = np.expand_dims(test_image, axis = 0) roi.jpg是保存在同一目录中的图像。

我有以下代码

from keras.preprocessing import image
    test_image = image.load_img('roi.jpg', target_size = (64, 64),grayscale=True)
    test_image = image.img_to_array(test_image)
    test_image = np.expand_dims(test_image, axis = 0)
roi.jpg是保存在同一目录中的图像。执行之后,我得到了以下错误

test_image = image.load_img('roi.jpg', target_size = (64, 64),grayscale=True)
File "C:\ProgramData\Anaconda3\lib\site-packages\keras\preprocessing\image.py", line 345, in load_img raise ImportError('Could not import PIL.Image. ')
ImportError: Could not import PIL.Image. The use of `array_to_img` requires PIL.
请帮我解决这个错误。我使用过
windows10

python版本:python 3.6.3::Anaconda custom(64位)

如果需要PIL模块,请尝试第一个模块,否则请尝试第二个模块

conda install PIL
conda install Pillow

或者,如果PIL和Pillow都存在,则卸载它们并重新安装PIL

,这样基本上该消息会告诉您安装PIL。你试过了吗?是的,我已经安装了枕头。但是没有解决它。@usr2564301 Thankui已经安装了第二个。但这不是解决办法,那PIL呢?是否已安装?conda install pil Solution environment:失败的不可满足错误:发现以下规范存在冲突:-pil-zict使用“conda info”查看每个包的依赖项@约翰:你能卸载PIL和枕头并重新安装PIL吗?@BibinJaimon如果对你有帮助,你可以接受我的回答,谢谢。