IPython Notebook error: Error loading notebook

IPython Notebook error: Error loading notebook

在过去的几分钟内,我无法访问之前使用 Python3.4 创建的任何 .ipynb 文件。我转到包含这些文件的子目录,输入

ipython3 notebook

当我打开 "New" 笔记本时,出现以下错误:

Unexpected error while saving file: Untitled1.ipynb database disk image is malformed

我也打不开旧笔记本。我收到错误:

An unknown error occurred while loading this notebook. This version can load notebook formats v4 or earlier. See the server log for details.

在终端内,它指出

kernels (twice to skip confirmation).
[E 00:30:22.352 NotebookApp] Unhandled error in API request
    Traceback (most recent call last):
      File "/opt/local/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/traitlets/traitlets.py", line 460, in get
        value = obj._trait_values[self.name]
    KeyError: 'db'

我该如何解决这个问题?

搜索 nbsignatures.db。它应该在这里:

~/.ipython/profile_default/security/nbsignatures.db

或此处:

 ~/Library/Jupyter/nbsignatures.db

~ 代表您的主目录。

将此文件移至临时目录。

重新启动您的 IPython 笔记本服务器。

删除 ~/.ipython/profile_default/history.sqlite

这对我有帮助。

由于找不到其他答案中提到的任何文件,我寻找了另一种解决方案,发现这个解决方案适合我:

I solved this problem by changing the ownership of the ~/.local/share/jupyter directory from root to user.

来自 https://github.com/ipython/ipython/issues/8997

这对每个人来说都不是问题,但我收到以下错误消息是因为磁盘实际上已满。

An unknown error occurred while loading this notebook. This version can load notebook formats v4 or earlier. See the server log for details.

其他答案对我的情况都没有帮助。

最后我干脆把我的笔记本抄了下来,改了个名字。 副本没有错误。

首先运行终端中的以下内容:

sudo jupyter notebook --allow-root

然后一些URL会出现在终端里,像:

http://localhost:8888/?token=f2704ecba4c88716337f33e79e13335380e25382603afb80

最后,将 URL 复制并粘贴到浏览器的新选项卡中。然后jupyter notebook会在新标签页中打开。

就我而言,我的nbsignatures.db在这里,删除后可以正常运行。

~/.local/share/jupyter/nbsignatures.db

记得重启你的 jupyter notebook 服务器。我重新启动了几次才能正常工作。