Import image in python

hello I am a beginner in python and I have problems executing my code . how can i fix this error with python:

import cgitb cgitb.enable() print('Content-type: text/html\r\n') print('\r\n') import Image, ImageDraw import sys import math, random from itertools import product from ufarray import * ModuleNotFoundError: No module named 'Image' args = ("No module named 'Image'",) msg = "No module named 'Image'" name = 'Image' path = None with_traceback = <built-in method with_traceback of ModuleNotFoundError 
2

3 Answers

Make sure you have installed Pillow (the supported, open-source version of the PIL Python Image Library) and then change your import to:

from PIL import Image, ImageDraw 

That should get you farther along.

Try this:

from PIL import Image 

or else you haven't installed it yet:

pip install pillow 

I had a similar Problem, this post helped me: How to insert an image in python

What they basically use is:

import Image myImage = Image.open("your_image_here"); myImage.show(); 

For more help I would need your full code. Even after the edit it is not quite clear to me what is your code, what is the error and what you are actually trying to do.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like