Answer a question

I have been editing a Jupyter Notebook for the past week, and tried saving it today. While attempting to save it, I got an error, so I refreshed the page and successfully saved it.

However, to my dismay almost all of my command history was lost! I still have access to the variables (the kernel never died), but I don't have access to any of the code.

Is there any way to recover the code? The kernel is still running, but I do not see any checkpoints in my notebook.

Answers

You can get the IPython history, which Jupyter Notebook uses as its kernel. In one of the cells run:

%history

This will dump a history (good, bad, and ugly) of every command you have run in the current IPython session. It is probably more than you want, but it is better than losing all your work.

Logo

Python社区为您提供最前沿的新闻资讯和知识内容

更多推荐