Jump to content
  • Advertisement
Sign in to follow this  

python importing woes

This topic is 2981 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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 = Image.open("twilight.png")
>>> im2 = PIL.Image.open("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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!