问题
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
回答1:
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.
回答2:
Try this:
from PIL import Image
or else you haven't installed it yet:
pip install pillow
回答3:
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.
来源:https://stackoverflow.com/questions/51321960/import-image-in-python