1

I've been working quite a lot with Python Add-Ins over the past week or so in a Windows 7 SP1 configuration with ArcGIS 10.3.1 for Desktop and ArcGIS Pro 1.0.2 installed. I also installed Python 3.4.1 that comes with ArcGIS Pro and two versions of Python were happily co-existing.

Every time I made changes to my Python script in the Install subfolder and then returned to the Python Add-In folder and double-clicked makeaddin.py I would see that my *.esriaddin file had been updated because its Date Modified changed in Windows Explorer.

Then I upgraded ArcGIS Pro to version 1.1 this morning, and the double-clicking of makeaddin.py ceased to update my *.esriaddin file. I also noticed that right-clicking on a *.py and choosing Edit with IDLE now opened it with Python 3.4.1 (from ArcGIS Pro 1.1) instead of 2.7.8 (from ArcGIS 10.3.1 for Desktop). I was able to get Edit with IDLE working the way I wanted it to by referring to Distinguishing Python version when using IDLE with ArcGIS Pro and ArcGIS 10.x for Desktop architecture?

However, double-clicking makeaddin.py still does not update my *.esriaddin file, so I know that something is astray with its file association. As a workaround I am able to right-click on makeaddin.py, Edit with IDLE (which is using Python 2.7.8) and use F5 (Run | Run Module) to run it. However, I am keen to get the double-click working again.

Does anyone have a sure-fire method to check and reset the ArcGIS installed version of Python that is run by double-clicking a *.py file?

That ArcGIS Pro installation changes Windows file associations for *.py files is documented but how to change them back is not:

Windows uses file associations to associate a file extension with an executable. When executing a file, the last installation that modifies that file association wins, so if there are multiple versions of Python, the last version installed will be the one used when a .py file is double-clicked or called from a command prompt. Additionally, if a version of Python is uninstalled, the file associations for a .py will be removed.

6
  • Can you modify the Windows Registry to change the file associations?
    – Fezter
    Jul 20, 2015 at 3:48
  • @Fezter I think it needs something more done in the registry than what I have managed so far. What precisely that is I have not yet been able to discern from links like social.msdn.microsoft.com/Forums/vstudio/en-US/…
    – PolyGeo
    Jul 20, 2015 at 4:39
  • There are a couple of interface tools to change file associations without digging in the registry. Thought this had been posted as an answer before, but maybe not. First method is right-click the file and choose Open or Open With. There's a check box in the resulting dialog that says 'Always use this program' or some such, so tick that and browse to the exe you want to associate. There's also a tool in the Control Panel called Default Programs that is pretty straightforward to use.
    – Chris W
    Jul 20, 2015 at 5:51
  • However, while you can change the association yourself, there's nothing to stop a program from automatically changing it back when run. Some programs have a setting in the options to disable this - I know a couple of media players like Winamp, Quicktime, VLC, and Windows Media Player all have things like that, sometimes called 'protect file associations' or similar. Quicktime barks at you every time you start it and one of its file types isn't associated with it, unless you turn off that nag warning. I've no idea if Pro will reset it on run or just install.
    – Chris W
    Jul 20, 2015 at 5:55
  • @ChrisW I think you're referring to gis.stackexchange.com/questions/140923/…. However, and I may be wrong, that seems to only take care of setting Open with and not what is used on a double-click.
    – PolyGeo
    Jul 20, 2015 at 5:55

1 Answer 1

4

I've figured this out with help from some nudging comments by @ChrisW on this question and an old answer by @MattWilkie.

Please only do the following at your own risk because I profess no system administration skills.

  1. I opened a CMD window from the Windows Start Menu as Administrator
  2. I checked the current file association for *.py files by typing:

    assoc .py=

which returned:

.py=Python.File

  1. I checked the current file type by typing:

    ftype Python.File

which returned:

Python.File="C:\Python34\python.exe" "%1" %*

  1. I changed the file type by typing:

    ftype Python.File="C:\Python27\ArcGIS10.3\python.exe" "%1" %*

Then without doing anything else, I tried clicking on my makeaddin.py file again and it updated the *.esriaddin correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.