Search code examples
python-3.xlinuxubuntuimporterror

Why am I getting a `ModuleNotFoundError: No module named 'Image'` error?


When I run my Python script, I get the following message:

ModuleNotFoundError: No module named 'Image'

I'm running Python 3.6 on Linux Ubuntu. The script named Fax_simulator contains:

import Image
# other code…

It's place in:

/home/CVS/facsim/venv

I've searched for the module and I've found it:

/usr/lib/python3/dist-packages/PIL/Image.py

Here are some lines of the code:

import Image
import ImageDraw
import ImageFont

Do I have to install it. And if Yes how? With PIP? I've got the PIP version 9.0.1 from Python 3.6. Is that alright?


Solution

  • You need to import them from the PIL package:

    from PIL import Image
    from PIL import ImageDraw
    from PIL import ImageFont
    
    # use Image
    

    Or alternatively:

    import PIL
    
    # use PIL.Image