PIL Open Problem

Richard Holmes richardh at dslextreme.com
Tue Feb 8 00:35:44 CET 2011


On Tue, 08 Feb 2011 09:47:32 +1100, Ben Finney
<ben+python at benfinney.id.au> wrote:

>Richard Holmes <richardh at dslextreme.com> writes:
>
>> I'm trying to create an image for use in Tkinter. If I understand the
>> PIL documentation correctly, I first need to import Image, then
>> create an instance of the Image class and call 'open' (this according
>> to the documentation). When I try to do this using the model in the
>> documentation, I get:
>
>Please show the code you used that generated this traceback.
>
>> Traceback (most recent call last):
>>   File "todo.py", line 202, in <module>
>>     im = Image.open(cwd + r'\delete.GIF', 'r')
>> AttributeError: class Image has no attribute 'open'
>
>The line of code shown in the traceback is calling the ‘open’ method on
>the ‘Image’ class – which has no such method, as the error tells you.
>
>> Can someone point out to me the folly of my ways?
>
>It will be much easier when we see some code. Post a minimal, working
>example that still shows the behaviour you want explained.

Thanks, Ben. It turns out that I imported both Image and Tkinter and
Tkinter has an Image class that masked the Image class in the Image
module. I solved the problem by moving the Image code to a separate
module




More information about the Python-list mailing list