5

Trying to edit a python file but the "edit command" has disappeared all of a sudden when I right click the file.

How do I restore the edit command so I can continue working on my python files?

I am using Windows Vista.

1

10 Answers 10

3

In Windows7 you can create the
HKEY_CLASSES_ROOT\SystemFileAssociations\.py\shell\edit\command
path and set its default value to
c:\python\pythonw.exe c:\python\Lib\idlelib\idle.pyw -e %1

2

I spent some time trying to figure this out. i finally got it. I'm running windows 7, but should be the same for vista, XP etc.

  1. uninstall python
  2. open registry (windows button+r, then type regedit and hit enter)
  3. push ctrl+f and type .py
  4. each .py key you come across, delete it.
  5. do this until it gives you the message: finished searching the registry

repeat this process but changing the search for the following querys:

.pyw
python
python.exe
pythonw.exe
  • delete them all.
  • log off from your user account
  • log back on
  • re-install python
1
  • 1
    While I am sure this will work, hence the +1, it is a bit along the lines of "nuke it to the bedrock and start from scratch"
    – Mokubai
    Jun 14, 2012 at 16:43
1

What exactly do you mean by the right click "edit command"? How did you originally install python and run and edit python files, which editor etc?

Have you considered using an IDE? I find that for development using eclipse IDE with pyDev is really good. Either that or pyscripter is fairly well known - http://code.google.com/p/pyscripter/downloads/list

If you want to continue as you were, try re-installing python, each version comes bundles with the Python IDLE which I expect is what you were using. - http://www.python.org/getit/

Then it should come back. If that fails:

  1. Search in regedit for the key: HKEY_CLASSES_ROOT*\shell
  2. Right click on "shell" and choose 'create new key'
  3. Name it "Edit with IDLE"
  4. Create a key below that and call it "command."
  5. Double click on the (Default) value that you will find in the right hand window pane, then type in the following: "python.exe %1" (or if you don't have it in your PATH, then put in the absolute python directory, for example: C:\Python27\bin\python.exe)

See some more links below for IDEs Editors etc:

http://wiki.python.org/moin/IntegratedDevelopmentEnvironments

https://stackoverflow.com/questions/60784/poll-which-python-ide-editor-is-the-best

https://stackoverflow.com/questions/126753/is-there-a-good-free-python-ide-for-windows

5
  • Hi Peter, so as an example, I have created and saved a python file. Lets call it test.py. I now would like to edit that file in idle. So normally i go to the file on my desktop and right click the file which opens up a menu that include edit. I then press edit which opens the file so i can making the necessary changes to the code.
    – Anonymous
    May 7, 2011 at 21:00
  • I have updated my answer to help you add back the "Edit with IDLE" command. I realised you were probably just using IDLE.
    – Peter Hamilton
    May 7, 2011 at 21:01
  • Peter i re installed python and still the "edit with IDLE" command does not show up. So i tried your steps above but i do not know what is regedit and how to find it. Could you please explain?
    – Anonymous
    May 7, 2011 at 22:15
  • Type regedit in the vista Start > Search Dialog Box and press enter
    – Peter Hamilton
    May 7, 2011 at 22:47
  • Okay tried your instructions above and did not work. When you say Create a key below that and call it "command.". Do you mean create a subfolder within edit with IDLE?. Because thats what i did. Also, should it automatically appear or would i have to do something else after following your instructions.
    – Anonymous
    May 8, 2011 at 1:37
0

Sounds like you're using Windows. You need to associate IDLE as the editor for .py files. I don't know about Windows 7 but with XP:

  • Open Windows Explorer, click on 'Tools' menu, select 'Folder Options'
  • Select 'File types' tab.
  • Scroll down and select "py Python File" in the Registered file type list.
  • Click the Advanced button to open the Edit File Type dialog box.
  • If you see "Edit with IDLE", click the Edit button and make sure the "Application used" box reads something like "C:\PythonXX\pythonw.exe" "C:\PythonXX\Lib\idlelib\idle.pyw" -e "%1" (replacing XX with your Python version.
  • If you don't see "Edit with IDLE", click the New button, enter "Edit with IDLE" in the Action box and the same "Application used" string as above, then check the DDE box.
0

Right click on the file, choose Open with, select choose default program, and select python.

Warning, this will attempt to run whatever script you are trying to open from the command prompt (but you can just x this out).

After that, the computer should recognize the file as a python file and give you the "Edit with Idle" option again.

0

In your registry find this entry:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Python.File\shell\Edit with IDLE\command

and replace the path to pythonw.exe with the path of the version you want to use by default. I'm guessing this path might have been pointing to something that no longer exists for OP.

0

A program you recently installed or launched might have changed the file association. Here's how I fixed mine in Windows 7:

  1. In Windows Explorer, right-click on your .py file and select "Properties".
  2. In "General" tab under "Type of file:" click the "Change..." button.
  3. Under "Recommended Programs" select "Python Launcher for Windows (Console)".
0

Save the text below into a .reg file using notepad and double-click on it.

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Python.File\shell\Edit with IDLE\command] @="\"C:\Python34\pythonw.exe\" \"C:\Python34\Lib\idlelib\idle.pyw\" -e \"%1\""

[HKEY_CLASSES_ROOT\Python.NoConFile\shell\Edit with IDLE\command] @="\"C:\Python34\pythonw.exe\" \"C:\Python34\Lib\idlelib\idle.pyw\" -e \"%1\""

If you are using Python27 change the "34"s above to "27"s. Restart your computer.

0

Create following key if not exists:

HKEY_CLASSES_ROOT\*\shell\Edit with IDLE\command

Now set value to default as:

c:\Pythonxx\pythonw.exe  c:\Pythonxx\Lib\idlelib\idle.pyw -e %1

Note: Replace xx with version number of Python installed.

1
  • 1
    That would add the context menu item for ALL files, not just Python files. Dean Spicer's REG is more appropriate.
    – w32sh
    Mar 30, 2016 at 13:34
0

A program you recently installed or launched might have changed the file association. Here's how I fixed mine in Windows 7:

In Windows Explorer, right-click on your .py file and select "Properties".
In "General" tab under "Type of file:" click the "Change..." button.
Under "Recommended Programs" select "Python Launcher for Windows (Console)".

Above answer from rtseno only seems to work for .py files, not .pyw files.

P.S. I cant comment yet so i made this an answer.

You must log in to answer this question.