I've recently installed Anaconda (using the default settings) on Windows 7. When I try to open a .py file by double-clicking it, I get the Open with...
option. How can I set the default program as Spyder
?

- 3,771
- 8
- 36
- 75
-
Be aware each answer matches only it's own unsaid assumption: Spyder installed as a stand alone .exe program (unlikely, but easy to answer as it's an OS feature) or Spyder as a .py script managed by Python engine (difficult to answer due to many different configurations, versions, and default conda environments to use -- this might explain why the developers [don't provide a solution](https://github.com/spyder-ide/spyder/issues/15534)). – mins Mar 12 '23 at 12:21
4 Answers
This is a variation based on Jose's solution of creating a .bat file that eventually worked for me.
Create a spyder.bat file with the following content:
start C:\YourPath\Anaconda2\pythonw.exe C:\YourPath\Anaconda2\cwp.py C:\YourPath\Anaconda2 "C:/YourPath/Anaconda2/pythonw.exe" "C:/YourPath/Anaconda2/Scripts/spyder-script.py" %1
Change YourPath to your actual Anaconda path. Other solutions didn't work for me, and the code here is inspired by Spyder shortcut's target.

- 1,331
- 9
- 25
You must create a spyder.bat file with the following content:
start C:\path\to\Anaconda3\pythonw C:\path\to\Anaconda3\Scripts\spyder-script.py %1
Remember set the path where Anaconda is installed.
Then, use the Open with...
dialog and select your new spyder.bat batch file.
It works on Windows 10 Home. I hope it works in Windows 7 too.

- 849
- 1
- 13
- 19
-
I just tried this on Windows 10 and it didn't work. It just opened Spyder without opening the file. – nick012000 Aug 09 '21 at 07:24
Use the "Default Programs" interface and select the executable for your Spyder,try the "Set Associations" menu and use browse to select your executable.
The key is the executable path(set the path where the anaconda is installed): C:\path\Anaconda2\Scripts\spyder.exe
just need to be patient, to wait for a few seconds.

- 67
- 4
-
1There is no spyder.exe executable, just a .py file that starts spyder – Rolando Gonzales Feb 11 '23 at 10:41
When you get the Open With... dialog, select the "Select a program from a list of installed programs" option.
Then make sure the "Always use the selected program to open this kind of file" option is selected. Click "Browse" to point to the Spyder executable.

- 5,336
- 1
- 29
- 52

- 57
- 9
-
3This doesn't work, because Spyder doesn't seem to have an executable. It has a shortcut to a .py file. I'd downvote, but I don't have the reputation on this site yet. – nick012000 Aug 09 '21 at 07:16