'How to recover unsaved file in spyder

Spyder crashed at the last minute and I had force quit the programme as it wasn't responding at all. After reopening it, I am not able to find my file that I was working on, i hadn't saved it and had quite a bit of code written in it. It will be a huge help if someone knows a way to recover it, and can guide me through it.

Thanks alot!



Solution 1:[1]

hist -g will show console history logs. You can recover your code from history if you had run your code earlier.

Solution 2:[2]

I experienced a similar situation where I had added code to existing script that later wasn't saved as I expected it to be. I was able to recover my code from the history log (copy and paste). Not a perfect solution, but much better than having to re-write the code.

I am on Spyder 3.3.4

Solution 3:[3]

Just for the people who still want to know the solution, close and open again Spyder application. It will ask you to recover the file. This worked for me today.

Solution 4:[4]

I'll comment to help in case (someone crazy like me) clicked the discard button when Spyder asked if you wanted to restore the file.

I found the following solution:

  1. open a new terminal
  2. cd /home/pc/.config/spyder-py3/
  3. code .
  4. open the history.py file
  5. Heart attack stopped successfully!

Anyway, you will no longer find the file you discarded in the autosave folder, however, in the history.py file are saved the last 1000 lines that you executed, in my case the last 30 were enough.

I hope it helps

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 KittenCrypto
Solution 3 Vishal singh rajpoot
Solution 4