22

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?

Medulla Oblongata
  • 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 Answers4

13

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.

xyzjayne
  • 1,331
  • 9
  • 25
5

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.

Jose Raul Barreras
  • 849
  • 1
  • 13
  • 19
1

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.

elecjack
  • 67
  • 4
-1

When you get the Open With... dialog, select the "Select a program from a list of installed programs" option.

Open With Dialog

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.

Browse

GingerPlusPlus
  • 5,336
  • 1
  • 29
  • 52
  • 3
    This 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