Reputation: 375
When I save a jupyter notebook with a plotly graph, I get the following error:
[E 13:42:38.458 NotebookApp] Notebook JSON is invalid: {'data': [{'type': 'scatter', 'y': [1, 2, 3]}], 'layout': {}} is not valid under any of the given schemas
Failed validating 'oneOf' in schema['properties']['data']['patternProperties']['^(?!application/json$)[a-zA-Z0-9]+/[a-zA-Z0-9\\-\\+\\.]+$']:
{'oneOf': [{'type': 'string'},
{'items': {'type': 'string'}, 'type': 'array'}]}
On instance['data']['application/vnd.plotly.v1+json']:
{'data': [{'type': 'scatter', 'y': [1, 2, 3]}], 'layout': {}}
My code in the notebook is :
import plotly.offline as py
import plotly.graph_objs as go
py.init_notebook_mode(connected=True)
data = [go.Scatter(y=[1,2,3])]
py.iplot(data)
Following plotly plots in jupyter notebooks: Validation fails when saving, I updated nbformat but still not working (I checked with import nbformat
nbformat__version__
that the update worked)
Upvotes: 5
Views: 1956
Reputation: 1
I got a different error -
Notebook validation failed: {'type': 'string'} is not valid under any of the given schemas: { "type": "string" }
But replacing "nbformat_minor": 1 with "nbformat_minor": 4 worked for me.
Upvotes: 0
Reputation: 371
I got the same problem. I tried updating nbformat and even conda update --all but this didn't help too.
Later I was given a link: https://gitmemory.com/issue/jupyter/nbformat/161/574959380. So, I opened ipynb file with text editor, replaced "nbformat_minor": 1 with "nbformat_minor": 4 and saved the file. After reloading the notebook the problem was fixed.
Upvotes: 4