我最近(昨天......)切换到了Anaconda,现在我遇到了ImageTk.PhotoImage的问题:
>>> im = Image.open(fn) # fn is a png image
>>> im
<PIL.PngImagePlugin.PngImageFile image mode=RGBA size=411x484 at
0x10F9D4750>
>>> imtk = ImageTk.PhotoImage(im)
Exception AttributeError: "'PhotoImage' object has no attribute
'_PhotoImage__photo'" in <bound method PhotoImage.__del__ of
<PIL.ImageTk.PhotoImage object at 0x10f9d45d0>> ignored
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/eduardomartinez/anaconda2/lib/python2.7/site-packages/PIL/ImageTk.py", line 112, in __init__
self.__photo = tkinter.PhotoImage(**kw)
File "/Users/eduardomartinez/anaconda2/lib/python2.7/lib-tk/Tkinter.py", line 3367, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "/Users/eduardomartinez/anaconda2/lib/python2.7/lib-tk/Tkinter.py", line 3304, in __init__
raise RuntimeError, 'Too early to create image'
RuntimeError: Too early to create image
这曾经工作过。任何线索?