-
Notifications
You must be signed in to change notification settings - Fork 569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use of SVG generates TypeError: Object of type 'bytes' is not JSON serializable #904
Comments
There's something really strange going on. if (
not isinstance(data, text_type)
or mime_type == 'application/json'
):
# Data is either JSON-like and was parsed into a Python
# object according to the spec, or data is for sure
# JSON. In the latter case we want to go extra sure that
# we enclose a scalar string value into extra quotes by
# serializing it properly.
data = json.dumps(data) assuming all non-string data to be otherwise valid json.
I don't know anything about json-data embedded in cells, but i don't think it's reasonable to assume all non-string data should be piped through |
This does actually seem to be in It uses nbconvert/nbconvert/preprocessors/svg2pdf.py Line 100 in 9a22426
|
This should be fixed in the nbconvert 5.5 release already. I believe this is supposed to be returning bytes and not a unicode string. |
FWIW, I am running with nbconvert 5.5.0 and I just got this error a few minutes ago trying to use the command to download as PDF through latex:
|
Update: this occurred for a notebook with an embedded graphic generated by |
Can you post the minimal notebook to reproduce? (might have to change the extension to post on the issue) |
@MSeal I'm attaching one that is minimal, but not runnable -- it has a huge dependency tail. But you should be able to open it and test the download as PDF, and if you see the same error as I do, should be able to see what it is in the file that triggers it (and reopen this issue?). |
I was able to convert your example notebook @rpgoldman, maybe double check that you are indeed using nbconvert 5.5.0? I used $ pip show nbconvert
Name: nbconvert
Version: 5.5.0
... It's possible that you have 5.5.0 installed but the server is not picking that one up. Double check the nbconvert version in the shell you are using to run the jupyter server. I ran |
@SpencerPark Sorry -- you were quite right: I was having a problem with my virtual environment so that the nbconvert that I was looking at, and the one that was being run by jupyter were two different things. Thanks for testing that.
|
When using SVG plots
the conversion to latex generate the error:
TypeError: Object of type 'bytes' is not JSON serializable
If I use PDF or PNG
or
No error is detected. I understand that this is an issue associated with the svg to json conversion. The log is:
The text was updated successfully, but these errors were encountered: