How to recover a notebook emptied after kernel crash?

前端 未结 3 557
迷失自我
迷失自我 2021-02-13 18:14

While working in an ipython notebook, eventually I had to Ctrl+C as the kernel seemed to be halted.

The console gave me a message like:

[NotebookApp] Ker         


        
相关标签:
3条回答
  • 2021-02-13 18:41

    You can check in .ipynb_checkpoints/ in the folder where your notebook was for recent enough version of IPython.

    0 讨论(0)
  • 2021-02-13 18:45

    There is a great writeup about different recovery options from "Jupyter Disasters" at [1].

    I want to quote one technique from there, namely opening $HOME/.ipython/profile_default/history.sqlite in the sqlite tool of your choice (e.g. sqlitebrowser) and digging around in there. This can be an option if there is no usable checkpoint file (as discussed in other answers).

    [1] https://medium.com/flatiron-engineering/recovering-from-a-jupyter-disaster-27401677aeeb

    0 讨论(0)
  • 2021-02-13 18:54

    If none of the above helped, I found a workaround to recover most of the changes I did since the last checkout - by simply calling this command in your notebook:

    %history -g
    

    If you want your IPython history in a plain-text file, you can export it yourself.

    You can also do it for a specific filename:

    %history -g -f filename 
    

    What does -g do? – Without -g it exports the history for the current session. With -g it exports history for all sessions.

    0 讨论(0)
提交回复
热议问题