This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Python 3.5.2 installer doesn't register IDLE .py extensions on Windows 10
Type: behavior Stage:
Components: Installation, Windows Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eryk sun, eryksun, frostyelsa, paul.moore, steve.dower, terry.reedy, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2016-12-19 11:31 by frostyelsa, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
dump_py_config.bat eryksun, 2016-12-21 20:57
py_config.txt frostyelsa, 2016-12-21 21:22
progress so far.png frostyelsa, 2016-12-21 23:41
double clicking on .py should show this.PNG frostyelsa, 2016-12-22 00:44
openwithidle_for_frostyelsa.reg eryksun, 2016-12-22 01:31
Messages (32)
msg283606 - (view) Author: David (frostyelsa) Date: 2016-12-19 11:31
"Edit with IDLE" option is also not present in my installation when I right-click on a .py file. And when I try to choose the IDLE application, it just defaults to the command line version every time. I don't know why this happens. I was able to run it fine on my Windows 7 and it recognized all my .py student files as IDLE-based which is exactly what I want: to see them in a script editing environment. 

Any help would be appreciated. All the proposed solutions online haven't helped.
msg283635 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-12-19 17:31
.py files are not 'IDLE based', even if edited with IDLE.  They are Python files and should normally be registered to run with Python directly, and not via IDLE.

The right click context menu *should* include "Edit with IDLE".  I have re-marked this issue for that problem, though I believe there is another issue about this.  I have Win 10 also and I have "Edit with IDLE >" which open submenu containing "Edit with IDLE 3.5 (64 bit)" and "Edit with IDLE 3.6 (64 bit)".  This is a Windows installer issue, not an IDLE issue per se.

I don't understand "And when I try to choose the IDLE application, it just defaults to the command line version every time".  If you mean that clicking the IDLE entry in the start menu brings up console Python, then something went wrong in your installation process.  Have you tried re-installing?  Are there any error messages while installing?
msg283640 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-12-19 18:15
I'm not familiar with any of the other proposed solutions - could you link to a few?

One important factor is that you need to install the Python Launcher to get the context menus (this is the default in 3.5 and later). Associating directly to the Python installation just causes conflicts when you install another version, so we set them up via the launcher instead. In effect, the launcher is the integration point between Windows Explorer and Python, and without it you only get the shortcuts.

Installing Python 2.7 and leaving the "Register Extensions" option selected will overwrite the context menu from Python 3.5 or later. So if you've installed 2.7 after 3.5 then I would strongly recommend running a Repair of 3.5.

Otherwise, answers to Terry's questions would also be helpful. It isn't entirely clear how you are "choos[ing] the IDLE application", or if the installations were successful.
msg283643 - (view) Author: Eryk Sun (eryk sun) Date: 2016-12-19 18:32
It looks like you've accidentally created and selected an auto-generated association between .py and python.exe. You should be able to restore the original file association to get the "Edit with IDLE" menu back. In Windows 10 the "open with" menu has an option to "choose another app". In the dialog select "always use this app to open .py files". Or go to the control panel's "default programs" app, and choose "associate a file type" and double click on ".py" in the list. Either way, select the "Python" entry with a rocket on the icon. Hopefully this selects the "Python.File" ProgId that was configured by Python's installer.

What we're trying to do here is modify the contents of the registry key "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\UserChoice". Python's installer doesn't have anything to do with this key. It's based on what the user selects in Explorer, and it's intentionally difficult for code to directly modify this key. It's protected by an access control entry that denies the user (i.e. programs running as the user) the right to modify the key directly, plus a hash of the user's selection. But one thing you can still do is to delete the key, which will restore the default user and system file association.
msg283650 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2016-12-19 21:23
Here is another possible reason (and cure) for intentionally installed  python to not work.  Just posted to Python list.

"Turns out that another instance of Python *was* installed, not as part of OEM software, but by a digital camera (Califone) that is being used in some of our classrooms.  The suggestion to look for environmental variables was the key  -  on the PCs where we were having the problem, there was a variable starting with PYTHON ... which pointed to the camera software.  Once the camera was uninstalled, Python 3.5.2 worked just fine."
msg283664 - (view) Author: David (frostyelsa) Date: 2016-12-20 04:02
I'm going to tackle the questions one-by-one: 

I would like these ".py" files to be IDLE files in the sense that they have the IDLE icon and they open up directly into an idle file with a shell in the background. For context: on my other Windows 10 machine, I've been able to amass a semester's worth of ".py" that are all opened by, and have the icon of, IDLE. 

I have tried to manually associate the ".py" in the "default programs" app with the IDLE application shortcut but to no avail. Instead of opening in IDLE it opens in the command line format (that black python icon). So basically it opens up for a fraction of a second and then closes. No bueno. 

I have tried repairing, installing and reinstalling Python on my machine all with the appropriate settings (and launcher included in all of those tries). No dice. Still no right-click context menu. Still no ability to have ".py" files open up with IDLE. 

Note: I _have_ been able to associate the ".py" extension with "idle.bat" -- this works. But that's not an acceptable workaround. There is something deeper wrong here that I cannot pinpoint. Is it in my installer? I have no idea. I've tried most everything...

Including deleting the UserChoice key/folder/whatever it is and still nothing producing. I even tried "idle.exe" but Windows 10 gives me the error: "This app can't run on your PC -- to find a version for your PC, contact the software publisher." Just great. 

There are no error messages on any install/reinstall/repair that I've managed to try. Everything goes smoothly from start to finish. But the product is broken. 

In addition: I've never programmed in 2.7 and have never installed it on my computer. All of my Python knowledge is based in 3.5.2: it was for a semester-long course. So even the repair that I did run (which didn't work) wouldn't be accounting for any potential conflicts with 2.7. 

Furthermore, I was not able to find a python rocket icon in my files even with hidden items in view so I was not able to complete the ".py" and ".pythonrocketapp" association. However, I did notice in my program/applications folder that Python Launcher was indeed installed on my computer at the very least. 

This is absolutely perplexing and I appreciate all of your help in troubleshooting this. Thank you, and Merry Christmas.
msg283668 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-12-20 05:24
The Python launcher is the right app to select. Double-clicking .py files has always run them with the interpreter, but you will also get the right-click menu once they are associated with the launcher (this is what I meant by it being the single integration point).

There has never been a time when double-clicking a .py file has opened in IDLE by default after installing any release from python.org. Associating with idle.bat is the best way to achieve this as we do not include any other launcher (and we don't support using idle.bat either, though it should work and we'll try and help you if it doesn't, but it's not a core scenario for the main distribution).
msg283671 - (view) Author: David (frostyelsa) Date: 2016-12-20 06:47
Thanks for the help Steve, however I cannot find the Python Launcher app anywhere on my computer. Even after repairing/reinstalling. Where might I find this file? What is it called exactly? Much appreciated.
msg283689 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-12-20 14:14
C:\Windows\py.exe (probably. If you changed from the default options it may be elsewhere, but if you Open With on a .py file it should be there)
msg283706 - (view) Author: Eryk Sun (eryk sun) Date: 2016-12-20 18:00
When you change the association for executing scripts (either via Default Programs or the Open with => Choose another app menu), do not "look for another app on this PC". Manually associating files with an executable such as py.exe creates a ProgId that's only meant for opening data files, i.e. there's no "%*" in the template to pass command-line arguments. (Microsoft should provide an option here to support passing command-line arguments.)

You have to select "Python" in the listed applications. Explorer lists them only by name and icon. There may be multiple entries named "Python". The one you're looking for should have a rocket on the icon because it opens using the py.exe launcher. Hopefully this should be for the "Python.File" ProgId that's configured by Python's installer. 

If switching to it doesn't add the IDLE menu, first confirm that the "ProgId" value is "Python.File" in the user choice registry key at the following path: "HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\UserChoice". If not, pick a different "Python" app from the list until the user choice is "Python.File". (Microsoft should provide an advanced way to select a ProgId explicitly. They took away the ability to edit the UserChoice key, which is fine, but they failed to provide an advanced alternative to the dumbed-down app list, which is hostile to both power users and developers.) If no entry sets the user choice to "Python.File" or if it's set to "Python.File" and there's no IDLE menu, then maybe the ProgId itself has been modified or deleted. Try repairing your Python installation to fix this.

Steve, you could move the "Edit with IDLE" menu out of the Python.File ProgId to an entry defined in SystemFileAssociations. This should normally be available regardless of the application the user associates with .py files. Here's an example .reg file to add this for a system install of 64-bit 3.5:

    Windows Registry Editor Version 5.00

    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.py]

    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.py\shell]

    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.py\shell\editwithidle]
    "MUIVerb"="&Edit with IDLE"
    "Subcommands"=""

    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.py\shell\editwithidle\shell]

    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.py\shell\editwithidle\shell\edit35]
    "MUIVerb"="Edit with IDLE 3.5 (64-bit)"

    [HKEY_LOCAL_MACHINE\SOFTWARE\Classes\SystemFileAssociations\.py\shell\editwithidle\shell\edit35\command]
    @="\"C:\\Program Files\\Python35\\pythonw.exe\" -m idlelib \"%1\" %*"
msg283709 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-12-20 20:33
> Steve, you could move the "Edit with IDLE" menu out of the Python.File ProgId to an entry defined in SystemFileAssociations.

I could, but I don't want to. I'd rather figure out adding an "Open With" entry for IDLE.

There's no reason to for IDLE to be a system-level association if the user has not chosen the association, just as I'd expect any text editor to be opt-in.
msg283712 - (view) Author: Eryk Sun (eryk sun) Date: 2016-12-20 23:36
> There's no reason to for IDLE to be a system-level association if 
> the user has not chosen the association

Ok, to clarify, SystemFileAssociations can be defined in either the system or user hive. It's fine if the IDLE menu is added this way when it's done just for the current user (perhaps with an addition option in the installer). The problem is setting it in the system hive for a per-machine install because an individual user won't be able to disable the menu.

> I'd rather figure out adding an "Open With" entry for IDLE

As you've suggested before, that requires bundling an idle.exe launcher.
msg283716 - (view) Author: David (frostyelsa) Date: 2016-12-21 02:15
So I tried changing it to py.exe, and it doesn't load the IDLE: instead, it opens up the run command for the program in command prompt. That's not what I want it to do. Also, there still is no Edit With IDLE option. And I tried doing the ProgID stuff, but none of it worked even after repairing/uninstalling, etc. 

I'm kind of hopeless at this point. Thank you everyone for helping.
msg283723 - (view) Author: David (frostyelsa) Date: 2016-12-21 09:06
Also, I created a reg file with the commands in a txt file and when I merged it, it was able to show the "Edit with IDLE" but it would do nothing. IDLE isn't there. Very perplexing.
msg283762 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-12-21 15:51
But you definitely have idle installed, right? The commands earlier made an assumption about your installation that could be wrong, so that would explain it.

I'm still not entirely clear whether you've done these steps yet:

1. Right-click a .py file and select Open With
1a. If this gives you a deeper menu, select Another App
2. Find the Python launcher in the window that appears and select it.
3. Select Always Open with this app check box
4. Click Open/ok/whatever button is on there

That should reset your personal customization back to the original shortcut.
msg283779 - (view) Author: David (frostyelsa) Date: 2016-12-21 20:26
Yes, I have IDLE installed, and Launcher is installed as well. I can open up IDLE from the shortcut, however I am not able to access it within "Open With" or "Default Programs" or "Change" (within Properties). I _can_ open up the file only if I open up IDLE first then click "File" and then "Open" of the .py file in question. But the process of doing that compared to just double-clicking the IDLE-associated .py file is enormous and a workaround I'm trying to avoid. 

I've done steps 1-4 on a clean installation however there is one thing missing: the Python Launcher. It does not appear in the list of programs to choose. I tried everything up to and including idle.bat. But I'm not going to use idle.bat, that is a workaround I'm also trying to avoid. I just want a correct installation. I think it has something to do with my OS preventing the Python Installer from tinkering with the "Open With" options. 

The original shortcut for a clean installation for me is the python run command in the command-prompt. I need to able to see the code in IDLE when I double click on a .py file. 

Thank you for your help.
msg283783 - (view) Author: Eryk Sun (eryk sun) Date: 2016-12-21 20:41
There are many possible points of failure, so I'd like to get a clearer picture of your system configuration. Please download and run the attached batch file "dump_py_config.bat" and upload the "py_config.txt" file that it creates.
msg283786 - (view) Author: David (frostyelsa) Date: 2016-12-21 21:22
Thank you for your help. Attached is the py_config.txt that your .bat file gave me.
msg283789 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-12-21 21:58
It looks like PyCharm has taken over your shortcut:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py\UserChoice
    Hash    REG_SZ    55jxudRhknE=
    ProgId    REG_SZ    PyCharm2016.3

If you delete the entire "FileExts\.py" key with registry editor then it should reset back to either our launcher, or give you the ability to choose.
msg283790 - (view) Author: David (frostyelsa) Date: 2016-12-21 22:06
Couple things: I installed PyCharm after all other options where exhausted. I needed to do some work on multiple projects. 

And also, I deleted .py key and it still doesn't show up. I tried associating it with idle.pyw and that didn't work either: Windows said it can't run that on my PC.
msg283793 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2016-12-21 22:45
Let's do a bit of house cleaning. Run the following commands in a command prompt:

    reg delete HKCU\SOFTWARE\Classes\.py /f
    reg delete HKCU\SOFTWARE\Classes\py_auto_file /f
    reg delete HKCU\SOFTWARE\Classes\Applications\python.exe /f
    reg delete HKCU\SOFTWARE\Classes\Applications\py.exe /f
    reg delete HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.py /f

HKCU\SOFTWARE\Classes\.py is selecting the PyCharm2016.3 ProgId. This takes precedence over HKLM\SOFTWARE\Classes\.py, the key that selects Python.File. I expect this causes Explorer to automatically reselect the PyCharm2016.3 ProgId. Deleting it in combination with deleting "...\Explorer\FileExts\.py" may fix the problem, i.e. restore the Edit with IDLE menu.

The "...\Applications\python.exe" and "...\Applications\py.exe" keys were created by manually associating with the given executable. Note how the open commands have the script path (%1) but no command-line arguments (%*). It's harmless to delete these keys.
msg283794 - (view) Author: David (frostyelsa) Date: 2016-12-21 23:37
Couple things to note: I was not able to delete a couple of the keys. Regardless I've made some progress which I will outline in the next comment.
msg283795 - (view) Author: David (frostyelsa) Date: 2016-12-21 23:41
Following your instructions on key deletion, I have now 2 "Edit with IDLE" options now. The top one does *not* work. The second one, however, does work. But when I tried to associate the .py with idle (so it opens up in IDLE) it reverted back to the command-line run of the .py file and eliminated the "Edit with IDLE" options from the right-click menu. Very odd. 

Thank you so much for staying with this issue.
msg283796 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2016-12-21 23:58
To remove the broken "Edit with IDLE" entry, open an elevated (administrator) command prompt and run the following:

    reg delete "HKLM\SOFTWARE\Classes\Python.File\shell\Edit with IDLE" /f
msg283797 - (view) Author: David (frostyelsa) Date: 2016-12-22 00:02
I did that, and now all the options are gone.
msg283798 - (view) Author: David (frostyelsa) Date: 2016-12-22 00:08
Also, just to clarify, I want this to be a regular installation of Python wherein I can associate .py files with IDLE (i.e. when I double click on a .py file, it takes me straight to the code) *as well as* having the option to "Edit with IDLE" when right-clicking on a .py file. For some reason, on this machine, I'm not able to replicate the same installation as on my other Windows machine not matter how much I try.
msg283799 - (view) Author: David (frostyelsa) Date: 2016-12-22 00:08
Also, just to clarify, I want this to be a regular installation of Python wherein I can associate .py files with IDLE (i.e. when I double click on a .py file, it takes me straight to the code) *as well as* having the option to "Edit with IDLE" when right-clicking on a .py file. For some reason, on this machine, I'm not able to replicate the same installation as on my other Windows machine not matter how much I try.
msg283800 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2016-12-22 00:19
> I did that, and now all the options are gone.

Removing the broken HKLM entry shouldn't have removed all of the options. The "Edit with IDLE" menu should be there as long as Python.File is selected for the file association. It's defined for the current user on your system, under the following key:

    HKCU\SOFTWARE\Classes\Python.File\Shell\editwithidle
msg283801 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2016-12-22 00:30
> I want this to be a regular installation of Python wherein I can 
> associate .py files with IDLE

That isn't a regular installation. It's not even an optional configuration, and never has been. You'd have to set that up manually. Are you looking to [-r]un files in IDLE by double clicking on them, or simply open them in the editor?
msg283802 - (view) Author: David (frostyelsa) Date: 2016-12-22 00:44
Before re-installing Windows 10, I was able to open up all my .py files  by double-clicking on them and it would open them up in the IDLE (where I could edit the code manually and what have you). I'm not sure why it's never been a feature: I was doing that for many months.
msg283803 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2016-12-22 01:31
openwithidle_for_frostyelsa.reg adds an open command for the current user that opens the target file in IDLE. This will take precedence over the per-machine open command that executes the file using the launcher. 

It also adds "Run" and "Run as administrator" commands to execute the file using the launcher.
msg283804 - (view) Author: David (frostyelsa) Date: 2016-12-22 01:56
Thank you so much! This solved it.
History
Date User Action Args
2022-04-11 14:58:40adminsetgithub: 73200
2017-01-02 04:42:04steve.dowersetstatus: open -> closed
resolution: not a bug
2016-12-22 01:56:18frostyelsasetmessages: + msg283804
2016-12-22 01:31:38eryksunsetfiles: + openwithidle_for_frostyelsa.reg

messages: + msg283803
2016-12-22 00:44:29frostyelsasetfiles: + double clicking on .py should show this.PNG

messages: + msg283802
2016-12-22 00:30:37eryksunsetmessages: + msg283801
2016-12-22 00:19:35eryksunsetmessages: + msg283800
2016-12-22 00:08:50frostyelsasetmessages: + msg283799
2016-12-22 00:08:31frostyelsasetmessages: + msg283798
2016-12-22 00:02:50frostyelsasetmessages: + msg283797
2016-12-21 23:58:49eryksunsetmessages: + msg283796
2016-12-21 23:41:12frostyelsasetfiles: + progress so far.png

messages: + msg283795
2016-12-21 23:37:15frostyelsasetmessages: + msg283794
2016-12-21 22:45:59eryksunsetnosy: + eryksun
messages: + msg283793
2016-12-21 22:06:29frostyelsasetmessages: + msg283790
2016-12-21 21:58:29steve.dowersetmessages: + msg283789
2016-12-21 21:22:58frostyelsasetfiles: + py_config.txt

messages: + msg283786
2016-12-21 20:57:33eryksunsetfiles: + dump_py_config.bat
2016-12-21 20:54:07eryk sunsetfiles: - dump_py_config.bat
2016-12-21 20:41:52eryk sunsetfiles: + dump_py_config.bat

messages: + msg283783
2016-12-21 20:26:05frostyelsasetmessages: + msg283779
2016-12-21 15:51:44steve.dowersetmessages: + msg283762
2016-12-21 09:06:19frostyelsasetmessages: + msg283723
2016-12-21 02:15:22frostyelsasetmessages: + msg283716
2016-12-20 23:36:55eryk sunsetmessages: + msg283712
2016-12-20 20:33:33steve.dowersetmessages: + msg283709
2016-12-20 18:00:43eryk sunsetmessages: + msg283706
2016-12-20 14:14:52steve.dowersetmessages: + msg283689
2016-12-20 06:47:05frostyelsasetmessages: + msg283671
2016-12-20 05:24:39steve.dowersetmessages: + msg283668
2016-12-20 04:02:45frostyelsasetmessages: + msg283664
2016-12-19 21:23:09terry.reedysetmessages: + msg283650
2016-12-19 18:32:45eryk sunsetnosy: + eryk sun
messages: + msg283643
2016-12-19 18:15:15steve.dowersetmessages: + msg283640
2016-12-19 17:31:43terry.reedysetnosy: + paul.moore, tim.golden, zach.ware, steve.dower
messages: + msg283635

assignee: terry.reedy ->
components: + Installation, Windows, - IDLE
2016-12-19 11:31:38frostyelsacreate