python - Jupyter 笔记本 : (OperationalError ('disk I/O error' , ))

标签 python jupyter-notebook

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

The history saving thread hit an unexpected error (OperationalError('disk I/O error',)).History will not be written to the database.

无论如何,notebook 中的剩余代码在那之后会正常执行。但是,当我尝试创建一个新的笔记本文件时,这个错误不允许我创建它,我收到以下错误:

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"
}  

我试着按照这个 answer并删除了 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 文件系统上无法可靠地工作,如本 link 中所述。 .

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

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

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

ipython profile create 

这将在 ~/.ipython/profile_default 下创建配置文件。 打开 ipython_config.py 并添加以下行:

c = get_config() #gets the configuration
c.HistoryManager.hist_file='/tmp/ipython_hist.sqlite' #changes history file writing to tmp folder

保存并重新打开内核,它现在应该可以工作了。有关修改配置的更多详细信息,请参见 here

如果配置文件已经存在那么直接在终端输入

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

这也应该有效。

关于python - Jupyter 笔记本 : (OperationalError ('disk I/O error' , )),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49175406/

相关文章:

python - Hadoop和python之间的端口冲突

python - 运行 python 代码的 :pyf % and :! python % 之间的区别

python - 使用 iris 示例加载 csv 时 tensorflow 的值错误

python - 如何使用不同的系列在 python 中制作数据框?

python - 无法在终端 : "execution_count": null 中执行 jupyter notebook

python - 在 pandas/numpy 中运行应用函数时访问元素的 2D 索引?

python - 使用三个查询执行联合 - SQLAlchemy

python - 用于检查元素是否在排序列表中的递归函数

python - 超出 IOPub 数据速率的 Jupyter Notebook 错误消息

pyspark - 如何在 EMR 笔记本中安装 .jar 依赖项?