Python Jupyter笔记本:(操作错误(';磁盘I/O错误';,))

Python Jupyter笔记本:(操作错误(';磁盘I/O错误';,)),python,jupyter-notebook,Python,Jupyter Notebook,我在运行现有的Jupyter笔记本文件时遇到以下错误 The history saving thread hit an unexpected error (OperationalError('disk I/O error',)).History will not be written to the database. 尽管如此,笔记本中剩余的代码在此之后仍能正常执行。但是,当我尝试创建一个新的笔记本文件时,此错误不允许我创建它,我得到以下错误: Error while saving file:

我在运行现有的Jupyter笔记本文件时遇到以下错误

The history saving thread hit an unexpected error (OperationalError('disk I/O error',)).History will not be written to the database.
尽管如此,笔记本中剩余的代码在此之后仍能正常执行。但是,当我尝试创建一个新的笔记本文件时,此错误不允许我创建它,我得到以下错误:

Error while saving file: python_notebook_ollie/Untitled2.ipynb disk I/O error
Traceback (most recent call last):
  File "/work/ollie/muali/miniconda3/lib/python3.6/site-packages/notebook/services/contents/filemanager.py", line 421, in save
    self.check_and_sign(nb, path)
  File "/work/ollie/muali/miniconda3/lib/python3.6/site-packages/notebook/services/contents/manager.py", line 440, in check_and_sign
    self.notary.sign(nb)
  File "/work/ollie/muali/miniconda3/lib/python3.6/site-packages/nbformat/sign.py", line 449, in sign
    self.store.store_signature(signature, self.algorithm)
  File "/work/ollie/muali/miniconda3/lib/python3.6/site-packages/nbformat/sign.py", line 207, in store_signature
    if not self.check_signature(digest, algorithm):
  File "/work/ollie/muali/miniconda3/lib/python3.6/site-packages/nbformat/sign.py", line 241, in check_signature
    self.db.commit()
sqlite3.OperationalError: disk I/O error
[W 15:08:48.093 NotebookApp] Unexpected error while saving file: python_notebook_ollie/Untitled2.ipynb disk I/O error
[E 15:08:48.094 NotebookApp] {
  "Host": "localhost:15695",
  "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0",
  "Accept": "application/json, text/javascript, */*; q=0.01",
  "Accept-Language": "en-US,en;q=0.5",
  "Accept-Encoding": "gzip, deflate",
  "Referer": "http://localhost:15695/notebooks/python_notebook_ollie/Traj_case_study.ipynb",
  "Content-Type": "application/json",
  "X-Xsrftoken": "2|96ae1fed|bde68f8333dd4b46b900b02246747fa4|1520496687",
  "X-Requested-With": "XMLHttpRequest",
  "Content-Length": "19",
  "Cookie": "_xsrf=2|96ae1fed|bde68f8333dd4b46b900b02246747fa4|1520496687; username-localhost-15695=\"2|1:0|10:1520518043|24:username-localhost-15695|44:NjE5MWZlMWIzMjdmNGE2N2FlZmQ3NmE3NzRlNmNiZmQ=|8062f4c541e5dcef0d8b4a2d7e75cc59f1d27197ac4633b9da64b7bb94aae7a4\"",
  "Connection": "keep-alive"
}  
我试着按照这个方法删除了history.sqlite文件,但是仍然出现了磁盘I/O错误

github上的一些线程说基于NFS的挂载可能会产生一些问题,但在过去,在我升级matplotlib包之前,它工作得很好。我现在已经降级了那个软件包,但我仍然无法摆脱这个错误

编辑:打开.ipynb文件时终端上显示的第一个错误是

The signatures database cannot be opened; maybe it is corrupted or  

encrypted. You may need to rerun your notebooks to ensure that they are trusted to run Javascript. The old signatures database has been renamed to ~/.local/share/jupyter/nbsignatures.db.bak and a new one has been created.

我可以让它工作,所以我会张贴我所做的。 我认为问题的原因是SQLite锁定在NFS文件系统上无法可靠地工作,如本文所述

答案也在这里给出,我将在这里更详细地写下步骤:

基本上,必须为ipython创建新配置或修改现有配置。名为ipython_config.py的配置文件可以在~/.ipython/profile_default中找到

如果默认情况下配置文件不存在,那么可以通过在主目录中键入以下内容来创建它

ipython profile create 
这将在~/.ipython/profile_默认值下创建配置文件。 打开ipython_config.py并添加以下行:

c = get_config() #gets the configuration
c.HistoryManager.hist_file='/tmp/ipython_hist.sqlite' #changes history file writing to tmp folder
保存它并重新打开内核,它现在应该可以工作了。可以找到有关修改配置的更多详细信息

如果配置文件已经存在,那么只需输入终端

ipython --HistoryManager.hist_file='/tmp/ipython_hist.sqlite'

这也应该行得通。

我按照上面的步骤进行操作,我不确定出了什么问题,但它完全破坏了Jupyter实验室(
print(“hello”)
需要约30秒才能渲染)

在我的例子中,我认为最初的问题是由于历史被破坏造成的(
~/.ipython/profile\u default/
有一个名为
历史被破坏-*
的文件,带有今天的时间戳)。根据Ankit的回答,我通过删除
~/.ipython/profile\u default/history.sqlite
清除了历史记录,从而解决了问题


注意:我还删除了在上述过程中创建的
config
文件

检查您的主磁盘配额,可能已满

对我来说,我在一台主机配额有限的服务器上运行jupyter。并发现随着使用pip的日益增多,
~/.cache/pip
变得非常大。也许我没有空间写我的主目录

所以我删除了
~/.cache/pip
,然后重新启动jupyter。我发现一切正常

都与错误有关。发生错误的原因可能是sqlite锁定在基于NFS的系统上无法正常工作。而且,我猜是当我试图通过我的PC创建一个隧道时触发的,因此,相同的笔记本文件在两台机器上运行?不过我还是不明白如何解决这个问题