10

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"?

Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251

3 Answers3

19

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
Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251
  • 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 :) – Remigijus Pankevičius Oct 23 '14 at 20:14
  • 2
    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`. – Mark Tolonen Oct 24 '14 at 02:29
  • 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](https://answers.microsoft.com/en-us/windows/forum/windows_7-files/why-cant-i-change-the-default-program-from-command/e59d3d85-7161-4d3a-914e-9aeb3c72f6cb) – hanitors Jun 03 '21 at 03:05
5

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" %*
Andrey Sobolev
  • 12,353
  • 3
  • 48
  • 52
  • 1
    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. – Bruce Dawson May 21 '15 at 23:52
  • 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 – MagTun Jun 25 '21 at 17:48
0

Right-click on .py file and set default program as python.exe

denfromufa
  • 5,610
  • 13
  • 81
  • 138
  • 2
    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 May 21 '15 at 23:49