Issue
A frustrating and persistent error keeps popping up on my Jupyter Notebook:
The save operation succeeded, but the notebook does not appear to be valid. The validation error was:
Notebook validation failed: Additional properties are not allowed ('id' was unexpected):
{
"metadata": {
"trusted": true
},
"id": "breathing-seventh",
"cell_type": "code",
"source": "import pandas as pd\nimport numpy as np\nimport re\nimport datetime\n\nimport json\nimport os\nimport copy\n\nimport seaborn as sns\nimport matplotlib.pyplot as plt",
"execution_count": 1,
"outputs": []
}
It points to my imports column which contains:
import pandas as pd
import numpy as np
import re
import datetime
import json
import os
import copy
import seaborn as sns
import matplotlib.pyplot as plt
I'm also using Plotly in the notebook and I'm unsure if the error was caused by Plotly. I looked up the error and used the fixes mentioned here but the error still persists.
Please Advise.
Solution
This is due to a fairly recent change in nbformat
, which was described in detail here. Basically, nbformat 4.5 introduced these id
tags (which you'll probably find in every cell if you look for them), so every notebook stored in an earlier format should not have those tags — if an early-format notebook has them, it's considered an error.
So somehow your notebook was partially updated to have id
tags, but not the nbformat listed in the notebook's metadata. This has also happened to me, and it's surely a bug. (I think the update is supposed to happen via nbformat
, in which v5.1.1 will automatically convert 4.x up to 4.5; but I have 5.1.2. That and every other package are as up-to-date as conda will give me, and I've restarted my jupyter server.)
Anyway, the way to solve this problem is to open up your notebook in a text editor. Scroll to the very bottom, where the last few lines should look something like this:
},
"nbformat": 4,
"nbformat_minor": 1
}
You should be safe to change that nbformat_minor
number to 5, save the file, and open the notebook again as usual. You won't get those notifications again.
Answered By - Mike
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.