Home>

I want to read one image for the time being before I CNN with keras using my own image.

Error message
-------------------------------------------- -------------------------------
ImportError Traceback (most recent call last)
<ipython-input-10-40216d0f648d>in<module>
      1 import keras
      2 from keras.preprocessing.image import array_to_img, img_to_array, load_img
---->3 temp_img = load_img ('RIMG6767.JPG')
~ \ Anaconda3 \ envs \ tensorflow \ lib \ site-packages \ keras_preprocessing \ image.py in load_img (path, grayscale, color_mode, target_size, interpolation)
    494 color_mode = 'grayscale'
    495 if pil_image is None:
->496 raise ImportError ('Could not import PIL.Image.
    497 'The use of `array_to_img` requires PIL.')
    498 img = pil_image.open (path)
ImportError: Could not import PIL.Image. The use of `array_to_img` requires PIL.</Code></pre>
<strong>Applicable source code</strong>
<pre><code data-language = "Python">import keras
from keras.preprocessing.image import array_to_img, img_to_array, load_img
temp_img = load_img ('RIMG6767.JPG')

After confirming that PIL is not installed on the navigator, install Pillow on navigator and succeed.
However, the error has not changed.
Then, when \ Anaconda3 \ envs \ tensorflow \ lib \ site-packages is opened with Explorer, the file of \ PIL and \ Pillow-5.3.0-py3.6.egg-info are confirmed.
I thought PIL wasn't installed ... and opened a terminal
If pip uninstall PIL is typed, it will appear that PIL is not installed.
Just pip uninstal Pillow and uninstall all Pillow.
Download Pillow from the navigator again.

Supplemental information (FW/tool version etc.)

We use Win 10, anaconda navigator to create an environment called tensorflow in addition to root, and work in that environment called tensorflow.