Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accidentally deleted a map(desktop) in jupyter notebook. HELP! #3631

Closed
Atero opened this issue May 22, 2018 · 26 comments · Fixed by #3673
Closed

Accidentally deleted a map(desktop) in jupyter notebook. HELP! #3631

Atero opened this issue May 22, 2018 · 26 comments · Fixed by #3673

Comments

@Atero
Copy link

Atero commented May 22, 2018

jupyterissue

Hi all,

I recently started to use python with jupyter notebook.
As I am not familiar with Python at all, I made a terrible mistake last night.
As you can see from the screenshot, I deleted a map - my desktop - as I wanted to have a better overview, but apparently this software/ program has the power to delete all my files on my desktop ?? And it is not in the bin neither, it was deleted directly !
Naïve as I am I never made a backup from my files on my desktop and consequently everything is gone..
I tried to recover my files through EaseUS Data Recovery wizard and Stellar Phoenix windows data recovery and it manages to find the files, though all of them (jpeg, videos, excel, ppt, ..) are 0kb hence I cannot recover them.

I am really upset and have no clue how I can recover everything..
I would really appreciate help !!
jupyterissue

Thanks,
A

@dsblank
Copy link
Member

dsblank commented May 22, 2018

They are probably in your .Trash folder. Depending on your OS, you'll find that in different locations. I believe that jupyter notebook uses this library: https://pypi.org/project/Send2Trash/ so you can check the details to see where it went.

@Atero
Copy link
Author

Atero commented May 22, 2018

Hi,
Thank you very much for your answer !! Glad to hear I might recover my files...
However as I said, I am an absolute beginner in Python, hence I am not sure what to do.
This "pip install Send2Trash" I need to write it in the black screen (the prompt) or in my text file ?
I guess if you can guide me or take a quick screenshot, it might help me better to understand

My apologies for this probably dumb answer.

@dsblank
Copy link
Member

dsblank commented May 22, 2018

No problem... we all start somewhere!

You don't need to install Send2Trash as it is already on your system. If you knew Python, you could look at the details of where it put your files.

What operating system on you using? If you are on Linux, your files might be here: ~/.local/share/Trash/files/

If you are on Mac or Linux, you could do this at the terminal command line:

find ~/ | grep Trash

@Atero
Copy link
Author

Atero commented May 22, 2018

Hi,

thank for your understanding.
I work on a windows 10 operating system, what do you recommend ?

@dsblank
Copy link
Member

dsblank commented May 22, 2018

I haven't used Windows since about 1995. But googling some key words gives:

Here's how to get the Recycle Bin on your desktop in Windows 10:

  • Select the Start  button, then select Settings .
  • Select Personalization > Themes > Desktop icon settings.
  • Select the Recycle Bin check box > Apply.

@Atero
Copy link
Author

Atero commented May 22, 2018

Thank you for your reply.
I'm afraid that this won't help, since my files were deleted through jupyter and in fact never ended up in my recycle bin, but were erased directly from my pc and consequently it seems that it cannot be recovered by any data recovery software.
But as you mentioned earlier there is a recycle bin with jupyter that I can access ?

Thanks in advance

@dsblank
Copy link
Member

dsblank commented May 22, 2018

I'm pretty sure that Jupyter will not delete the files, but moves them to the system Recycle bin if possible. Deleting entire directories was not added until after the "send to trash" feature was added.

@Atero
Copy link
Author

Atero commented May 22, 2018

Apparently they do delete files or folders directly.. The space on my disk went from 50gb to 100gb directly after , hence my request to recover this.. I cannot imagine I am the first one that has encountered this ..
If you assume that my deleted files went to my local trash bin on my computer, I can assure you it did not.
Does anyone has any ideas ?

@takluyver
Copy link
Member

What version of Jupyter notebook do you have? In a command prompt, run jupyter notebook --version to check.

What does Python give you for import sys; sys.platform ? It should be "win32" for Windows, but it's worth double checking, because if it doesn't recognise the platform, it might have tried to use the Linux trash system.

But if the free disk space has increased as you say, it has probably somehow bypassed any kind of trash. I'd like to figure out how that happened, but for your files probably the only chance is to try some other 'undelete' tools. I don't know any to recommend, though.

@takluyver
Copy link
Member

@hsoft do you know of any conditions where send2trash might really delete a directory instead of putting it in trash?

@Atero
Copy link
Author

Atero commented May 23, 2018

Hi takluyver,
Thank you for taking the time to help me,
Apparently I have version 5.4.0
And i get win32 as well.
I already used advances recovery tools and although they found them, I cannot recover any..
It is almost impossible that everything was deleted directly from my pc..
Any ideas? Or someone else has similar experience ?

@ghost
Copy link

ghost commented May 23, 2018

On windows? It's been a long long while since I touched anything related to windows. I seem to remember that in some cases, Windows would offer to delete a file directly when it couldn't send it to trash (files over a network share) but IIRC, send2trash would just fail to process this kind of file.

@Atero
Copy link
Author

Atero commented May 23, 2018

Hence, no solution whatsoever?

@takluyver
Copy link
Member

If 50 GB of disk space has become free and recovery tools aren't working, I'm pretty sure that data is gone. The only thing I can suggest is to try a different recovery tool; maybe there are different techniques they can use, and some other tool will be able to recover some of your files.

What I'm still trying to work out is how this could happen.

send2trash seems to be doing a 'delete' file operation and setting the FOF_ALLOWUNDO flag to make that mean 'put it in the recycle bin'. However, the docs for that flag mention that it only allows undoing 'if possible'. Some SO questions suggest that there are situations where files can still be really deleted:

The second question and this linked codeguru thread mentions a few possible ways around this, none of them great:

  • The FOF_WANTNUKEWARNING will display an interactive Windows 'are you sure' dialog box. But if you've just clicked yes to one are-you-sure warning, you'll probably grumpily click yes to another one. And if you access Jupyter remotely, the Windows dialog won't show up remotely, and it will probably just hang.
  • There's apparently some way to do it with the newer IFileOperation interface, but the sample code is pretty complicated in C++; I'm not volunteering to do that through ctypes.
  • There's an undocumented IRecycleBinManager interface that can apparently do it.

I'm really surprised that Windows doesn't appear to have any convenient API to trash a file but error out if it's not possible to move it to the recycle bin. 😕

@Atero
Copy link
Author

Atero commented May 23, 2018

Thanks for your reply,
However your explanation is too technical for me to understand.
As you can see on the screenshot I have made when I started this discussion, all I did is confirm to delete my folder -being desktop- to delete without realizing that this program would have the power to delete all of these without apparently having the opportunity to get it back..
There must be a way to recover, I cannot imagine that jupyter can be a super advanced program to delete files, whithout a change of recovering it. Or is this an additional feature? ;)
If so, I will use jupyter as anew method when I want to delete files permanently!

Joking aside, I need my folders back!

@takluyver
Copy link
Member

Sorry. The technical details are me trying to figure out what happened. The summary is:

  • Jupyter is meant to send files to the recycle bin rather than permanently deleting them.
  • It appears that this doesn't always work, and sometimes the files really get deleted. We didn't realise this before. It's not clear exactly when this can happen - maybe if the files are too big?
  • Try some more recovery tools, besides the ones you already tried. Maybe you'll have more luck. If not, sorry, those files are probably gone.

Jupyter is a programming tool, and the default assumption for programmers is that if you tell the computer to do something, it does it. Always check what's in a folder before deleting it!

@Atero
Copy link
Author

Atero commented May 23, 2018

Thank you for your elaborated answer.
If anyone can recommend a program that might help to recover files after a programming tool has deleted it, let me know

@Atero
Copy link
Author

Atero commented May 25, 2018

Maybe there is a way I can recover a parts (few gigabytes) of what I lost?

takluyver added a commit to takluyver/notebook that referenced this issue Jun 10, 2018
It appears that the Windows backend of send2trash can't guarantee that
files won't actually be deleted. There are some hints that this happens
in particular when you delete a lot of data at once. So this returns to
refusing to delete folders unless they're empty (or contain only ipynb
checkpoints).

Closes jupytergh-3631
@minrk minrk added this to the 5.6 milestone Jun 15, 2018
@alwadey
Copy link

alwadey commented Jul 30, 2018

What is new @Atero?
Today, the same thing happened with me!!

@JaiminBhatporia
Copy link

I had committed the same mistake but all the files ended up in my recycle bin. My problem was solved after I restored everything from the recyclebin. I am using Windows 10 32-bit.

@DEXTERS2020
Copy link

The same thing happened with me today, I deleted my desktop folder.

@adyaan1989
Copy link

Hi all,

please let me know if data can recover from python. same happened with me

@yousuftufail
Copy link

Hi there,

Can anyone help me. I accidentally delete everything from my computer using Jupyter. There are so many important folders that I have deleted. My whole PhD thesis. My all certification work.
Can anyone please please help me. The space in my hard drive is increased now. I have also checked recycle bin, files and folders are not there. I was trying to open jupyter from Anaconda. It did not open and went to website and then I did that stupidity. Please any one can help this regard

@takluyver
Copy link
Member

I'm going to summarise the available information about this, to the best of my knowledge.

  • We're sorry if you've been bitten by this. Losing loads of data is scary, and it's a really terrible bug that the delete feature could sometimes bypass the recycle bin.
  • This should have been fixed in notebook 5.6, released over a year ago (PR Don't trash non-empty directories on Windows #3673). Check your version with the command jupyter notebook --version.
    • If you have an older version, upgrade - but this won't bring your data back if it was already deleted.
    • If you believe you hit the bug with notebook 5.6 or newer, open a new issue, and try to describe what happened in detail.
  • If you've got files missing, check in the recycle bin first: some or all of them might be there.
  • If they're not there, hopefully you have backups. Even without this bug, hard drive failures happen. Ransomware happens. If you've got any important files, don't rely on just one computer to store them.
    • If you're using a service like Dropbox or Google Drive, it may offer some limited backups of the files you kept in it.
  • If you don't have any backups, there are file recovery tools out there which might be able to help you. Your computer doesn't normally erase the data for deleted files, it just marks the area as empty and writes over it when it's saving some other data. There are tools which can scan the space marked as empty and find files in there. This is a last resort, and there's no guarantee it works, but if you're desperate it's something to try.

That's about all the information I can give anyone.

@takluyver
Copy link
Member

One more thing:

  • The fix was that Jupyter will refuse to delete folders on Windows unless they're empty. You can still delete individual files, and in some circumstances (maybe if your disk is almost full?) they could skip the recycle bin. But that should be harder to delete a lot of stuff by accident.

@AustinDickieson
Copy link

I may have accidentally deleted some files as well, however I am on Mac and am using Jupyter Notebook version 6.0.3. Where would I look or are they still permanently gone?

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants