Chapter 8 image does not open #5
-
Hi and thanks for a great book! I just have an issue opening the image after the filter is applied and I try to run the Jupyter commands. The response from the post action is fine (below), so there must be something with the filters code. Hope someone can help?
The following error is returned `--------------------------------------------------------------------------- C:\ProgramData\Anaconda3\lib\site-packages\PIL\Image.py in open(fp, mode) UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x000002AE80FDAB28>` |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
@AlexAdamov Thank you for raising this. Can you share a copy of your Jupyter notebook or the code that you are using please? |
Beta Was this translation helpful? Give feedback.
-
@AlexAdamov
This should solve the problem
Can you try this and let me know if it solves your problem please? |
Beta Was this translation helpful? Give feedback.
-
Hi thanks for the quick reply. The error happens one step before the typo at image = Image.open(io.BytesIO(response.content)). |
Beta Was this translation helpful? Give feedback.
-
OK. What is happening is your These commands needs to be run in the same notebook as where the previous commands were. In the comments notice it says Alternatively, what you can do is add the following snippet to your 4 lines above and rerun
Let me know if this works |
Beta Was this translation helpful? Give feedback.
-
The last alternative - all in one cell worked :-) It's strange because I ran the same commands in 4 separate cells (but in the same notebook) and for some reason it didn't identify the io.BytesIO object in the fourth cell. Thanks for helping out. You book has been very useful! |
Beta Was this translation helpful? Give feedback.
-
Just for your knowledge, this could have happened because you may have shutdown the notebook / VSCode. The cell execution results do not persist across restarts.
🙂 Always encouraging to hear good things, if possible please leave a review so it gets more exposure. |
Beta Was this translation helpful? Give feedback.
OK. What is happening is your
response.content
is empty and thus raising an error. It is empty becauseresponse
was the defined earlier in the notebook (beginning of Section 8.5) and your commands seem to be standalone.These commands needs to be run in the same notebook as where the previous commands were. In the comments notice it says
In[4]
which means it's the fourth cell in a series of commands.Alternatively, what you can do is add the following snippet to your 4 lines above and rerun