Import image in python

一曲冷凌霜 提交于 2020-01-24 10:22:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!