How to recover a notebook emptied after kernel crash?

£可爱£侵袭症+ 提交于 2020-01-02 01:20:36

问题


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] Kernel  shutdown: 5faa86bf-........f6 
[NotebookApp] Kernel  shutdown: 71........22 
[NotebookApp] ....

(I had three notebooks running)

But something went wrong and my notebook file.ipynb is empty (actually only the one I was actively using).

Is there a way to recover that file before it was deleted? Some place where automatically-saved o manually-saved versions are stored?

(Running python 2.7 (Anaconda) in Windows 7)


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/20356086/how-to-recover-a-notebook-emptied-after-kernel-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!