Jaume Clave
Jaume Clave

Reputation: 93

Jupyter Notebook to HTML - Notebook JSON is invalid: ['outputPrepend']

I am trying to convert my Jupyter Notebook file (.ipynb) into an HTML file for easier reading. Every time I try to save the notebook I get a "Notebook validation failed" error:

Notebook validation failed: ['outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend'] has non-unique elements:
[
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend",
 "outputPrepend"
]

message when file is saved

When I try to download as .html using File > Download as, I get a further more detailed error but I still cannot make out what it means or what needs to be done to solve the problem and finally download as HTML:

nbconvert failed: ['outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend', 'outputPrepend'] has non-unique elements

Failed validating 'uniqueItems' in code_cell['properties']['metadata']['properties']['tags']:

On instance['cells'][70]['metadata']['tags']:
['outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend',
 'outputPrepend']

message when trying to download as HTML

This is only happening on the specific notebook I am working on. I have tried to save and export other notebooks as HTML successfully.

Any help is appreciated. Thanks

Upvotes: 8

Views: 1465

Answers (1)

Jacob Lauritzen
Jacob Lauritzen

Reputation: 2840

I recently experienced this from using the VSCode Notebook editor. I solved it by opening the notebook in a regular text editor and deleting all the extra outputPrepend-items, leaving only a single one in each array.

Upvotes: 14

Related Questions