-2

I have a problem with my Python program. While running this program on an IDE (spyder IDE) I obtain no error and it works perfectly. Otherwise, if I run it in the python IDLE I obtain the following error.

 RESTART: C:\Users\jeane\Documents\Cours\BSP sem2\TechnicalPart\CNNLuminosity\Serverside\finalCnnOutput.py 
Using TensorFlow backend.
Traceback (most recent call last):
  File "C:\Users\jeane\Documents\Cours\BSP sem2\TechnicalPart\CNNLuminosity\Serverside\finalCnnOutput.py", line 43, in <module>
    test_image = image.load_img('blab-cam' + str(i) + '-snapshots/gallery-images/latest.png', target_size = (64,64))
  File "C:\Users\jeane\AppData\Local\Programs\Python\Python36\lib\site-packages\keras_preprocessing\image\utils.py", line 108, in load_img
    raise ImportError('Could not import PIL.Image. '
ImportError: Could not import PIL.Image. The use of `load_img` requires PIL.

I think this error has to something with the Python path environment variable since I can't find the module.

halfer
  • 19,824
  • 17
  • 99
  • 186

2 Answers2

1

You have to install the Pil module.It has nothing to do with the python path.

PIL is deprecated, and pillow is the successor.

pip install pillow

For More

Community
  • 1
  • 1
teddcp
  • 1,514
  • 2
  • 11
  • 25
0

You have to update the environment as below if you are not specific to the versions

pip install --upgrade tensorflow keras numpy pandas sklearn pillow

But if you are specific to versions then

pip install pillow

Note: If only install pillow then you need deactivate and reactivate the virtual environment.

halfer
  • 19,824
  • 17
  • 99
  • 186