Silicon's blog

Menu
  • Home
  • Kadena
  • Solana
  • Ethereum
  • Bot Automation
  • Proxmox
  • Nginx Proxy Manager
  • Others
  • Contact
Menu

How to autorestart your python script on crash using Spyder on Windows 10

Posted on May 14, 2023May 17, 2023 by Silicon
Sharing is Caring:
Twitter 0
Copy 0

 

Python is an easy-to-use language. Developers can build up an automation tool quickly using libraries provided by others. However, if it is crashed during execution and there is no exception handling script, it will not restart automatically. This article will introduce a way to handle exceptions and restart your Python script once it is terminated on your Windows 10 system.

Prerequisite: You have to install Spyder on your system. You may also look at my other article about how to set up an auto-start Python script on Spyder.

Step 1: Install Restart On Crash on your Windows 10 system.

Step 2: Right-click the shortcut of Spyder. Copy everything on the Target column.

Step 3: Click the Add button on Restart On Crash.

Enter the content until the .exe you copied before. In my case, it is C:\ProgramData\Anaconda3\pythonw.exe.

Tick It isn’t running and Execute a command:.

Paste the content you copied under Execute a command. In my case, it is C:\ProgramData\Anaconda3\pythonw.exe C:\ProgramData\Anaconda3\cwp.py C:\ProgramData\Anaconda3 C:\ProgramData\Anaconda3\pythonw.exe C:\ProgramData\Anaconda3\Scripts\spyder-script.py

Click the OK button after configuration.

Step 4: Spyder will be executed automatically on start/crash.

You may add

os.system('pkill -f "spyder3"')

to your exception handling (remember to import os). Spyder will restart automatically.

Leave a Reply Cancel reply


The reCAPTCHA verification period has expired. Please reload the page.

©2025 Silicon's blog
Click to Copy