Python 使用PIL和Urllib检索URL时未找到图像

Python 使用PIL和Urllib检索URL时未找到图像,python,python-2.7,tkinter,python-imaging-library,urllib,Python,Python 2.7,Tkinter,Python Imaging Library,Urllib,无论尝试使用哪个图像url,我都会不断收到以下错误: line 76, in <module> radar = Label(root, image = im) File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2556, in __init__ Widget.__init__(self, master, 'label', cn

无论尝试使用哪个图像url,我都会不断收到以下错误:

line 76, in <module>
    radar = Label(root, image = im)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2556, in __init__
    Widget.__init__(self, master, 'label', cnf, kw)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk/Tkinter.py", line 2055, in __init__
    (widgetName, self._w) + extra + self._options(cnf))
TclError: image "<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=538x190 at 0x105D4A830>" doesn't exist

我相信使用标签需要照片,我不确定如何最好地继续。多谢各位

对我来说,下面的代码很有效。请检查您是否也这样做:

import urllib, io

from Tkinter import *
from PIL import Image, ImageTk


root = Tk()

fd = urllib.urlopen("http://www.google.com/images/srpr/logo11w.png")
imgFile = io.BytesIO(fd.read())
im = ImageTk.PhotoImage(Image.open(imgFile)) # <-- here
image = Label(root, image = im)
image.grid(row = 7, column = 1)

root.mainloop()
导入urllib,io
从Tkinter进口*
从PIL导入图像,ImageTk
root=Tk()
fd=urllib.urlopen(“http://www.google.com/images/srpr/logo11w.png")
imgFile=io.BytesIO(fd.read())

im=ImageTk.PhotoImage(Image.open(imgFile))#那么你试过使用PhotoImage吗?是的,不过运气不好<代码>键错误:
import urllib, io

from Tkinter import *
from PIL import Image, ImageTk


root = Tk()

fd = urllib.urlopen("http://www.google.com/images/srpr/logo11w.png")
imgFile = io.BytesIO(fd.read())
im = ImageTk.PhotoImage(Image.open(imgFile)) # <-- here
image = Label(root, image = im)
image.grid(row = 7, column = 1)

root.mainloop()