How do you change file association for .py Python files in XP?

15,101

Solution 1

It appears Photoshop may recognize a .py file format and has associated "py_auto_file" with the .py extension.

You can use the following command to locate the python file types:

C:\>ftype | findstr -i python
Python.CompiledFile="C:\Python27\python.exe" "%1" %*
Python.File="C:\Python27\python.exe" "%1" %*
Python.NoConFile="C:\Python27\pythonw.exe" "%1" %*

The next command shows the correct associations from my system:

C:\>assoc | findstr -i python
.py=Python.File
.pyc=Python.CompiledFile
.pyo=Python.CompiledFile
.pyw=Python.NoConFile

You can fix the associations with the following commands:

assoc .py=Python.File
assoc .pyc=Python.CompiledFile
assoc .pyo=Python.CompiledFile
assoc .pyw=Python.NoConFile

Solution 2

You should pass script name %1 and all command-line parameters %* to Python27 executable. To do this, simply execute

ftype py_auto_file="C:\Python27\bin\python.exe" "%1" %*
Share:
15,101
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin almost 2 years

    When I type assoc .py I get .py=py_auto_file. When I type ftype py_auto_file I get py_auto_file="C:\Program Files\Adobe\Photoshop 7.0\Photoshop.exe" "%1"

    How do I make py_auto_file="C:\Python27"?

  • Remigijus Pankevičius
    Remigijus Pankevičius over 9 years
    Thanks! After upgrading from Pyton 2.5 to 2.7 I found I have same issue and your fix helped. Now I have dangling ftype-s "py_auto_file="D:\Python25\python.exe" "%1" %*" (same with pyc_auto_file) I'd like to remove. Do you know how to remove them? (Tried ftype /h, of course :)
  • Mark Tolonen
    Mark Tolonen over 9 years
    I think just setting them to blank: ftype py_auto_file=. You can also delete them directly under HKEY_CLASSES_ROOT in the registry via regedit.exe.
  • Bruce Dawson
    Bruce Dawson almost 9 years
    This doesn't pass command-line arguments along. If you do this then you need to edit the py_auto_file entry in the registry to add %* to the end of the command line.
  • Bruce Dawson
    Bruce Dawson almost 9 years
    This didn't work for me but I found the py_auto_file entry in the registry and added %* to the end and that fixed my problems. This was the error message I got when running the recommended ftype command: File type 'py_auto_file' not found or no open command associated with it.
  • hanitors
    hanitors almost 3 years
    Under windows 10, this solution may not work if you have this key in your registry: HKEY_CLASSES_ROOT\Applications\python.exe just delete this key, and it will work, otherwise you will need to modify the "command" entry to include the %* at the end of the command. link
  • MagTun
    MagTun almost 3 years
    If you get File type 'py_auto_file' not found or no open command associated with it. or File type 'PythonFile' not found or no open command associated with it. then you should try by opening CMD as admin