Sign in to follow this  

python importing woes

Recommended Posts

I am trying to use a Python library which accepts PIL images as input. However, I kept getting strange errors.

Eventually, I discovered that the problem is that I imported PIL using import Image whereas the library imported it with import PIL
and Image and PIL.Image appear to behave differently.

Anyway, I am a beginner to Python so I haven't seen this before. What is the reason for the incompatibility? What can I do to prevent this?

>>> im ="twilight.png")
>>> im2 ="twilight.png")
>>> isinstance(im, Image.Image)
>>> isinstance(im, PIL.Image.Image)
>>> isinstance(im2, Image.Image)
>>> isinstance(im2, PIL.Image.Image)

Edit: On further insepction, it looks like the library isn't even consistent with its type checking. In some places it uses isinstance(im, PIL.Image.Image) and in other places, isinstance(im, Image.Image).
Maybe I should just try to extract the useful bits of the library and strip out all the type checking.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this