Set Python IDLE as the default program to open .py Extensions

I am on Windows 7 . I have Python 2.7.8 (64 bit) installed. Today I changed the default program, which opens .py files from IDLE in the Windows Command Processor and stupidly selects a checkbox that says "always use the selected program to open such a file."

What I want to do is change my default program to IDLE.

When I try to change it to IDLE, I go to Control Panel\Programs\Default Programs\Set Associations and select the name .py and select Change Program. I see python.exe , but the choice does nothing. Then I use the Browse button to go to C:\Python27\Lib\idlelib , but I don’t know if I should choose idle.py , idle.pyw , idle.bat or some other IDLE program that will force the program to default be IDLE!

Nothing happens after choosing one of them.

How to make IDLE a default program that opens .py files and now disconnects Windows Command Processor from the default?

+6
source share
2 answers

If the flag always uses the selected program to open this type , the flag is grayed out , uncheck it:

  • Open regedit Go to
  • HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Explorer \ FileExts
  • Find the .py extension among the list
  • Delete UserChoice (folder)

Then you can go to: C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Python XX and select IDLE ...

or

browse to C:\...\PythonXX\Lib\idlelib\idle.bat and select this.


---- If you are upgrading from a previous version of Python ----

I just upgraded from Python 3.4 to Python 3.5, and it was a nightmare setting IDLE as my default program. I spent so much time. I finally got to the place where I no longer need to right-click and select IDLE. Instead, I just click on the .py file and it opens IDLE by default ... and it has a legit-looking Python icon (and not an ugly .bat icon).

I publish this, so basically I will remember how I did it!

  • Remote Python 3.4 using the control panel (Windows).
  • Excluded remaining folder C: \ Python34.
  • I went to the registry:

    • Start window (bottom left)> enter run> enter regedit in the Run dialog box.
    • Looked in the following areas and completely deleted python keys:
      • HKEY_CURRENT_USER \ Software
      • HKEY_LOCAL_MACHINE \ SOFTWARE
      • HKEY_USERS.DEFAULT \ Software
      • HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node
    • (Optional, use with caution). In the left pane of the registry editor, right-click and select Find. I looked in keys, values ​​and data, but just look at the keys. I removed those that looked very specific to running the procedures. You can press F3 to find again each time. enter image description here
  • I ran CCleaner specifically to remove / clean the registry, as well as to clean up temporary folders and just general maintenance. Run it several times.

  • Reboot the computer.
  • Install the new version of Python. If the installation fails for the first time, consider canceling some of the “advanced options” during installation. Example: "loading binary files for debugging". enter image description here
  • After installation, .py files cannot be associated with the program. You can go to the control panel and establish file associations. enter image description here
  • Locate the .py extension and click the "Change program" button in the upper right corner. Find the idle.bat location. Example: C:\Python35\Lib\idlelib . Click the idle.bat file and click OK.

At this point, you can click on the python file (file with the extension .py) and it will open using the idle idle.bat program. I read that sometimes this does not work for some people.

But now the .py file icon looks like a .bat program icon. This seems like crap, so I took the following steps to associate the Python icon with .py files.

  1. Run> run> regedit (run registry editor)
  2. In the registry editor, go to: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\UserChoice and pay attention to Progid (Applications \ idle.bat in my example). enter image description here
  3. If UserChoice does not exist, go to HKEY_CLASSES_ROOT\.py and note the value (default) (for example: py_auto_file). enter image description here
  4. I did not know what to change, so I changed BOTH .

    • Go to: HKEY_CLASSES_ROOT\Applications\idle.bat . The "DefaultIcon" folder does not exist, so I right-click idle.bat and select New> Key and name it "DefaultIcon". For the default data, I put C:\Python35\Lib\idlelib\Icons\idle.ico to reference the .ico image that is in the IDLE icon folder. folder with default icons added

    • Go to: HKEY_CLASSES_ROOT\py_auto_file and follow the same steps as step 12.1. added ico in py_auto_file

  5. Reboot the computer.

Final result

After all these steps, I can now double-click the .py file on Windows and it will run the file in Python IDLE.

+2
source
  • Right click on any .py file
  • Click "Open with ..."
  • Click Choose default program ...

    If IDLE is on the list, click it.

    else

    Click Browse, and find the IDLE program

  • Click OK and voila!

-1
source

Source: https://habr.com/ru/post/972939/


All Articles