I am on Windows 7. I have Python 2.7.8 (64 bit)
installed. Today, I changed the default program that opens .py
files from IDLE to Windows Command Processor and stupidly selected the checkbox that said "always use the selected program to open this kind of file".
What I want to do is change my default program back to IDLE.
When I attempt to change it back to IDLE, I go to Control Panel\Programs\Default Programs\Set Associations
and select the .py
name and click Change Program. I do see python.exe
but selecting that does nothing. I then use the "Browse" button to navigate to C:\Python27\Lib\idlelib
but don't know if I should select idle.py
, idle.pyw
, idle.bat
or some other IDLE program that will force the default program to be IDLE!
Nothing happens after I select one of these.
How do I make IDLE be the default program that opens .py
files and now disassociate Windows Command Processor from being the default?
py) in the file manager, right-click it, and select Properties. Click the "Open With" tab and select the application you want to use for that file type. Use the Set as default button to make the application the default application. From now, clicking on a python file should open your preferred editor.
To run a file of code that we're editing in IDLE, select the file's text edit window, open that window's Run pull-down menu, and choose the Run Module option listed.
If the "always use the selected program to open this kind of file" checkbox is grayed out, ungray it by:
Then you can navigate to:
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python XX
and choose IDLE...
or
navigate to C:\...\PythonXX\Lib\idlelib\idle.bat
and select that.
---- If You are updating from a previous version of Python ----
I just updated from Python 3.4 to Python 3.5 and it was a nightmare setting IDLE as my default program. I wasted so much time. I finally got it to where I no-longer have to right-click and select IDLE. Instead, I just click on a .py file and it opens IDLE by default... and it has a legit-looking Python icon (not an ugly .bat icon).
I'm posting this so mainly I'll remember how I did this!
Went into registry:
F3
to find again each time.
I ran CCleaner specifically to remove / clean-up the registry, but also to clean up temp folders and just general maintenance. Run it several times.
idle.bat
. Example: C:\Python35\Lib\idlelib
. Click the idle.bat file and press OK.At this point, you should be able to click a python file (file with .py extension) and it will open using IDLE's idle.bat program. I've read that sometimes this doesn't work for some people.
But now, the icon of .py files look like the icon of the .bat program. This looks like crap so I did the next steps to associate a Python icon with .py files.
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\UserChoice
and make note of the Progid
(Applications\idle.bat in my example).
HKEY_CLASSES_ROOT\.py
and make note of the (Default) value (ex: py_auto_file).
I didn't know which to change so I changed BOTH.
Go to: HKEY_CLASSES_ROOT\Applications\idle.bat
. A "DefaultIcon" folder didn't exist so I right-clicked idle.bat and chose New > Key and named it "DefaultIcon". For the (Default) data, I put C:\Python35\Lib\idlelib\Icons\idle.ico
to reference the .ico image that's within the IDLE icons folder.
Go to: HKEY_CLASSES_ROOT\py_auto_file
and did the exact same steps as step 12.1.
End-result
After all these steps, I am now able to double-click a .py file in Windows and it launches the file in Python IDLE.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With