Python PIL load throwing AttributeError: 'NoneType' object has no attribute 'read'

前端 未结 2 499
太阳男子
太阳男子 2021-01-20 20:59

I\'ve been struggling with this error for several days with little headway. Basically, I\'m trying to read in an image file and then use PIL to preform a specific operation

相关标签:
2条回答
  • 2021-01-20 21:32

    This is a silly thing, but I ran into this same error and spent at least an hour trying to find a solution. However the problem was actually mine, the filename I was passing was blank and caused it to throw this error........ Ugh.. Would have been nice if the library said "oh, you are missing the filename" instead of 'NoneType' object has no attribute 'read'. This was on a raspberry pi and python 2.7 just FYI.

    0 讨论(0)
  • 2021-01-20 21:38

    Maybe remove the call to verify(), or put a second call to open() between verify() and load()?

    The documention on verify() here says:

    ...if you need to load the image after using this method, you must reopen the image file.

    0 讨论(0)
提交回复
热议问题