Mit*_*hev 6 anaconda jupyter jupyter-notebook anaconda3
我已经安装了 Anaconda 3。当我运行 Jupyter Notebook 并保存一些内容时。出现下一个问题:
C:\ProgramData\Anaconda3\lib\site-packages\nbformat_ init _.py:128: MissingIDFieldWarning: 代码单元缺少 id 字段,这将成为未来 nbformat 版本中的硬错误。normalize()
您可能希望在验证之前在笔记本上使用(自 nbformat 5.1.4 起可用)。以前版本的 nbformat 正在透明地解决此问题,并且将来将停止这样做。验证(nb)
C:\ProgramData\Anaconda3\lib\site-packages\notebook\services\contents\manager.py:353: MissingIDFieldWarning: 代码单元缺少 id 字段,这将成为未来 nbformat 版本中的硬错误。normalize()
您可能希望在验证之前在笔记本上使用(自 nbformat 5.1.4 起可用)。以前版本的 nbformat 正在透明地解决此问题,并且将来将停止这样做。validate_nb(model['content']) [I 23:27:05.005 NotebookApp] 开始缓冲 956f2cf8-4baa-4f41-a715-89fc3e1b078c:7228c4b40f9241eb968ac5f8c1af
其中 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
目前尚不清楚您的问题是什么,所以我将解释此警告以及如何解决它。
无论出于何种原因,您的一个单元格“缺少 id 字段”,目前会产生一个MissingIDFieldWarning
,但“将成为未来 nbformat 版本中的硬错误”。您可以在文本编辑器中打开相关的 Jupyter 笔记本,您应该在其中看到id
每个单元格的字段,例如:
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "0945defe",
...},
...]
Run Code Online (Sandbox Code Playgroud)
显然,(至少)其中一个单元缺少该字段,即使它是必填字段并且应该自动生成。
您收到的警告已经包含有关如何解决此问题的建议:
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)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5445 次 |
最近记录: |