Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Validation fails when using plotly in jupyter notebook

Tags:

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)

like image 314
A.Vignon Avatar asked Oct 24 '17 12:10

A.Vignon


1 Answers

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.

like image 101
TopCoder2000 Avatar answered Sep 30 '22 00:09

TopCoder2000