[英]Notebook validation failed Jupyter
这不是Notebook Validation Failed的副本。
我有一个 Jupyter ntb,它直到最近都运行良好。 无论我做什么,我都会遇到那些正在发生变化的错误(我附上了一些例子),我对 ntb 做了什么并不重要(我尝试重新启动 kernel,重新启动 Jupyter)。 此外,它仅在此 ntb 中发生,即使在同一时间从同一个 session 运行,也不会在其他 ntb 中发生。 我试图搜索但找不到任何东西。 我在 Jupyter 中得到的是:
其中有很多,相似但不同:
The save operation succeeded, but the notebook does not appear to be valid. The validation error was:
Notebook validation failed: Non-unique cell id 'geological-poker' detected. Corrected to 'front-hampshire'.:
"<UNKNOWN>"
或其他:
Notebook validation failed: Non-unique cell id 'medieval-nebraska' detected. Corrected to 'stock-eating'.:
"<UNKNOWN>"
Notebook validation failed: Non-unique cell id 'intense-award' detected. Corrected to 'blocked-garage'.:
"<UNKNOWN>"
我在终端得到的是:
Notebook JSON is invalid: Non-unique cell id 'medieval-nebraska' detected. Corrected to 'convinced-vacation'.
或者
Notebook JSON is invalid: Non-unique cell id 'medieval-nebraska' detected. Corrected to 'described-commerce'.
Notebook JSON is invalid: Non-unique cell id 'meaning-victoria' detected. Corrected to 'occasional-numbers'.
Notebook JSON is invalid: Non-unique cell id 'eastern-buyer' detected. Corrected to 'english-benchmark'.
知道发生了什么以及如何解决它吗?
更新:它以某种方式修复了一段时间,但后来又开始做同样的事情我仍然不明白它是什么以及它是如何被修复和再次破坏的......一个解决方法是制作一份 ntb 的副本,然后丢弃旧的。
9.10.21 更新:
看起来这对于 python v3.8.11
来说不再是问题了。 自从更新所有软件包以来,我还没有设法重现该问题,因此现在最简单的解决方法可能是更新。 我有:
jupyter core : 4.7.1
jupyter-notebook : 6.4.3
ipython : 7.26.0
ipykernel : 6.2.0
我还碰巧找到了另一个有效的解决方案:
首先 select Jupyter Notebook 中的所有单元格,然后按“剪切/剪刀”按钮(不要惊慌,此时您的 Notebook 将是空的),最后按“粘贴”按钮。
这是来自https://github.com/jupyter/notebook/issues/6001#issuecomment-959828688 。
我有同样的问题,在阅读后,似乎原因是从其他会话中创建的其他笔记本复制/粘贴单元格。 我还没有找到修复它的方法,但至少你可以通过复制单元格的内容而不是单元格本身来防止它发生。
使用已解决的单元名称问题重新保存笔记本的代码:
import nbformat as nbf
from glob import glob
import uuid
def get_cell_id(id_length=8):
return uuid.uuid4().hex[:id_length]
# -- SETUP
nb_name = 'my_notebook'
# -- MAIN
# grab notebook
notebooks = list(filter(lambda x: nb_name in x, glob("./*.ipynb", recursive=True)))
# iterate over notebooks
for ipath in sorted(notebooks):
# load notebook
ntbk = nbf.read(ipath, nbf.NO_CONVERT)
cell_ids = []
for cell in ntbk.cells:
cell_ids.append(cell['id'])
# reset cell ids if there are duplicates
if not len(cell_ids) == len(set(cell_ids)):
for cell in ntbk.cells:
cell['id'] = get_cell_id()
nbf.write(ntbk, ipath)
来源: https://github.com/jupyter/notebook/issues/6001#issuecomment-856303981
首先 select Jupyter Notebook 中的所有单元格,然后按“剪切/剪刀”按钮(不要惊慌,此时您的 Notebook 将是空的),最后按“粘贴”按钮。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.