I am working on a project that heavily depends on Jupyter notebooks. Specifically, I have hit a bump when parsing notebooks to extract the cell outputs.
I found out that Matplotlib plots or any image generated using code gets saved into the underlying JSON as “image/png”. For example:
Used the route of my_str_as_bytes from this stackoverflow post to convert your string text to bytes.
However, I found that replacing the str.encode(string) part of my suggested code with string.encode(), and according to Antti Haapala’s answer that may perhaps be better.