How to recover deleted iPython Notebooks

后端 未结 12 807
礼貌的吻别
礼貌的吻别 2020-12-03 11:05

I have iPython Notebook through Anaconda. I accidentally deleted an important notebook, and I can\'t seem to find it in trash (I don\'t think iPy Notebooks go to the trash).

相关标签:
12条回答
  • 2020-12-03 11:37

    This is bit of additional info on the answer by Thuener,

    I did the following to recover my deleted .ipynb file.

    1. The cache is in ~/.cache/chromium/Default/Cache/ (I use chromium)
    2. used grep in binary search mode, grep -a 'import math' (replace search string by a keyword specific in your code)
    3. Edit the binary file in vim (it doesn't open in gedit)
      • The python ipynb should file start with '{ "cells":' and
      • ends with '"nbformat": 4, "nbformat_minor": 2}'
      • remove everything outside these start and end points
    4. Rename the file as .ipynb, open it in your jupyter-notebook, it works.
    0 讨论(0)
  • 2020-12-03 11:38

    If you are running on Jupyterlab on linux like me. What I did is went into command prompt and went to my trash folder.

    Trash directories on linux are typically

    /home/$USER/.local/share/Trash
    

    or

    If you deleted something as root (e.g. deleted a file using Nautilus invoked via gksu), it is at

    /root/.local/share/Trash
    

    I ended up changing directories to /home/$USER/.local/share/Trash/files and my deleted notebook was there! depending on how you access your backend you could also try /home/jupyter/.local/share/Trash/

    ps If you are having issues changing directories from Trash to files due to permissions dont forget to become root:

    sudo -i
    

    and the move to your files from there.

    Best of luck,

    0 讨论(0)
  • 2020-12-03 11:43

    If you deleted it through the OS (rm file.ipynb) then you can probably get it from ~/.ipython_checkpoints/ However, if you deleted it from the browser menu option, it is gone (by design!).

    See discussion here: https://github.com/jupyter/notebook/issues/405

    0 讨论(0)
  • 2020-12-03 11:46

    For the unlucky ones like me, that delete some files on JuliaBox(jupyter for julia), there is a solution. I successifly recovery all my deleted files.

    The browsers strore cache information about the pages you visit. You have to find your cache browser folder (in ubuntu with crhome was ~/.cache/google-chrome/Default/Cache) and grep for some text of your notebook in the binarys. Then, cut the text part of the file that is correspond to your ipynb.

    https://groups.google.com/forum/#!searchin/julia-box/delete%7Csort:relevance/julia-box/Rt9LG9RldrU/3s_vVSrivJEJ

    0 讨论(0)
  • 2020-12-03 11:46

    If you use PyCharm, you can do the following.

    1. Open the Local History view.

    2. Select the version you want to roll back to.

    3. On the context menu of the selection, choose Revert.

    Worked for me!

    Source: here

    0 讨论(0)
  • 2020-12-03 11:50

    As long as your Kernel is active, the code of each executed cell is stored in input history list. This will come in handy when you accidentally deleted a cell and want to retrieve its content.

    _ih[-10:] *# code of the 10 most recently run cells (Even if those cells are deleted now)*
    
    0 讨论(0)
提交回复
热议问题