在JupyterLab中打开.ipynb时出错-“不保存即关闭?”

时间:2020-04-04 16:07:53

标签: jupyter-notebook jupyter jupyter-lab

当我尝试打开我的.ipynb时,出现以下错误。同一目录中的其他笔记本也可以正常工作。

UI错误:

Close without saving?
File "cloner.ipynb" has unsaved changes, close without saving?Close without saving?
File "cloner.ipynb" has unsaved changes, close without saving?

浏览器控制台错误:

serverconnection.js:192 GET http://localhost:8890/api/contents/cloner.ipynb?type=notebook&content=1&1586015957921 400 (Bad Request)
handleRequest @ serverconnection.js:192
makeRequest @ serverconnection.js:76
get @ index.js:477
get @ index.js:170
(anonymous) @ context.js:498
Promise.then (async)
_revert @ context.js:497
initialize @ context.js:190
(anonymous) @ manager.js:445
Promise.then (async)
_createOrOpenDocument @ manager.js:445
open @ manager.js:274
openOrReveal @ manager.js:298
_handleOpen @ listing.js:824
_evtDblClick @ listing.js:900
handleEvent @ listing.js:543


context.js:582 Uncaught (in promise) TypeError: Failed to execute 'text' on 'Response': body stream is locked
    at Context._handleError (context.js:582)
    at context.js:540
_handleError @ context.js:582
(anonymous) @ context.js:540
async function (async)
_handleError @ context.js:582
(anonymous) @ context.js:540
async function (async)
(anonymous) @ context.js:536
Promise.catch (async)
_revert @ context.js:533
initialize @ context.js:190
(anonymous) @ manager.js:445
Promise.then (async)
_createOrOpenDocument @ manager.js:445
open @ manager.js:274
openOrReveal @ manager.js:298
_handleOpen @ listing.js:824
_evtDblClick @ listing.js:900
handleEvent @ listing.js:543

Pip管理的软件包版本:

Name: jupyter
Version: 1.0.0
Summary: Jupyter metapackage. Install all the Jupyter components in one go.

Name: jupyterlab
Version: 2.0.1
Summary: The JupyterLab notebook server extension.

我尝试删除.ipynb_checkpoints文件夹,并在git中跟踪所有这些内容。

查看Jupyter日志,我发现由于nbsignatures.db数据库被锁定,该错误再次出现。 https://www.onooks.com/jupyter-fails-to-open-notebook-with-error-file-xx-has-unsaved-changes-close-without-saving/

2 个答案:

答案 0 :(得分:1)

看起来像git merge冲突,在我的文件中添加了非json行。

使用文本编辑器在cloner.ipynb源文件中进行查找:

<<<<<<< HEAD
  },
  {
   <CONTENTS OF MY CELL>
   ]
=======
>>>>>>> a23f8f8f9db0974b7de90c6e7ed8599fa04d53cc

删除了这些非json行,然后重新营业。

答案 1 :(得分:1)

就我而言, jupytext 使我无法打开ipynb文件,因为我是使用其他编辑器而不是相应的python文件编辑ipynb文件的。

所以我对rm CORRESPONDING.py进行了攻击,然后就可以打开ipynb文件。