Reputation: 71
I have already intalled Anaconda 3.When I run Jupyter Notebook and save something. The next problem appears:
C:\ProgramData\Anaconda3\lib\site-packages\nbformat_init_.py:128: MissingIDFieldWarning: Code cell is missing an id field, this will become a hard error in future nbformat versions. You may want to use normalize()
on your notebooks before validations (available since nbformat 5.1.4). Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future.
validate(nb)
C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\contents\manager.py:353: MissingIDFieldWarning: Code cell is missing an id field, this will become a hard error in future nbformat versions. You may want to use normalize()
on your notebooks before validations (available since nbformat 5.1.4). Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future.
validate_nb(model['content'])
[I 23:27:05.005 NotebookApp] Starting buffering for 956f2cf8-4baa-4f41-a715-89fc3e1b078c:7228c4b40f9241eb968ac5f8c1af
where python --> C:\ProgramData\Anaconda3\python.exe C:\Users\Mitko Stoychev\AppData\Local\Programs\Python\Python310\python.exe C:\Users\Mitko Stoychev\AppData\Local\Microsoft\WindowsApps\python.exe
where jupyter (base) --> C:\Users\Mitko Stoychev>where jupyter C:\ProgramData\Anaconda3\Scripts\jupyter.exe
Upvotes: 7
Views: 7503
Reputation: 880
It is not clear what your question was, so I will explain this warning and how to fix it.
For whatever reason, one of your cells is "missing an id field", which for now produces a MissingIDFieldWarning
, but "will become a hard error in future nbformat versions".
You can open the Jupyter notebook in question in a text editor, where you should see an id
field for each cell, e.g.:
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "0945defe",
...},
...]
Apparently this field was missing for (at least) one of the cells, even though it is a mandatory field and should be produced automatically.
The warning you got already includes a suggestion on how to fix this problem:
import nbformat
with open("problematic_notebook.ipynb", "r") as file:
nb_corrupted = nbformat.reader.read(file)
nbformat.validator.validate(nb_corrupted)
# <stdin>:1: MissingIDFieldWarning: Code cell is missing an id field,
# this will become a hard error in future nbformat versions.
# You may want to use `normalize()` on your notebooks before validations (available since nbformat 5.1.4).
# Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future.
nb_fixed = nbformat.validator.normalize(nb_corrupted)
nbformat.validator.validate(nb_fixed[1])
# Produces no warnings or errors.
with open("fixed_notebook.ipynb", "w") as file:
nbformat.write(nb_fixed[1], file)
Upvotes: 4