9

I have just started to work with Python 3.4.1 which comes with ArcGIS Pro 1.0.0, on my laptop, which also has Python 2.7.8 which comes with ArcGIS 10.3 for Desktop installed, and I would like to minimize the chances of running one version of Python when I intended and needed to use the other.

In Windows Explorer, I now have two Python folders: C:\Python27 and C:\Python34 which is to be expected.

On the Windows Start Menu under All Programs > ArcGIS there is a Python 2.7 folder with the IDLE (Python GUI) that I often use to start IDLE, so starting it from here should be fine. I tested and it does start 2.7.8.

enter image description here

I had expected to see Python 3.4 folder next to Python 2.7 or maybe under All Programs > ArcGIS > ArcGIS Pro but it is in its own folder directly under All Programs. It contains another IDLE (Python GUI) that starts 3.4.1 as expected.

enter image description here

However, things become a little confusing when I look at the list of programs on the Start Menu because there are two IDLE (Python GUI) entries to choose from:

enter image description here

By right-clicking on each and using the General tab of their Properties I have renamed them to be called IDLE (Python GUI) 2.7 and IDLE (Python GUI) 3.4 respectively so once again there is no confusion.

enter image description here

The other way that I usually start IDLE is by right-clicking on a *.py file and then choosing Edit with IDLE - but the Python version of IDLE I will get is now ambiguous. By testing I find that it is 3.4.1.

enter image description here

Is there a way that I could turn my one choice of Edit with IDLE into these two choices?

  • Edit with IDLE 2.7; and
  • Edit with IDLE 3.4

I never edit with PythonWin so if I am limited to two programs that can be associated with *.py files for editing then I am happy to sacrifice Edit with PythonWin for Edit with Python 3.4.

  • 1
    Why not? PythonWin is much better than IDLE (IMHO)... You should be able to add custom actions in explorer and select your 'opens with', I remember doing that on windows NT and XP to have multiple choices of editors for the same file extension. Perhaps ask on superuser about that sort of thing, I'm not sure where the customize dialog has disappeared to in win 7/8.. – Michael Stimson Mar 31 '15 at 3:57
  • @MichaelMiles-Stimson PythonWin is an additional install and IDLE is fully fit for my purposes so using that is one more thing I can keep vanilla. – PolyGeo Mar 31 '15 at 5:02
  • Each to their own PolyGeo. I like PythonWin because it has (or had at the time) better InteliText, EOL markers, indentation guides, syntax checking, inconsistent indentation warning and interactive window. I have got used to it and haven't even looked at IDLE for years so I don't know if it has improved since ArcGis 9.0. – Michael Stimson Mar 31 '15 at 5:12
  • PythonWin also has great debugging capabilities, including a handy Watch window which lets you quickly see multiple variables' values – Stephen Lead Mar 31 '15 at 5:45
8

That's all controlled from the registry.

You could open the registry and find HKEY_CLASSES_ROOT\\Python.File\\shell\\Edit with Idle and re-name that folder to something like Edit with Idle 2.7

You could then add a new reg key (for example copy this into notepad and save as "Idle3.4.reg", then double click to install the reg key)

Windows Registry Editor Version 5.00

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

It goes without saying, but I'll say it anyway - don't play in your registry unless you're comfortable that you might break something and have trouble putting it back together again.

9

This is not exactly what you asked for, but a workaround could be to add both IDLE instances to your Send To context menu option.

  • open %APPDATA%\Microsoft\Windows\SendTo
  • choose > New > Shortcut
  • specify the path and command for IDLE, eg C:\Python27\ArcGIS10.2\pythonw.exe "C:\Python27\ArcGIS10.2\Lib\idlelib\idle.pyw"
  • repeat for the other IDLE version

enter image description here

Now when you right-click on a Python script you'll have to the option to Send To either IDLE version:

enter image description here

  • 1
    That's what I was thinking of, that way you can decide at the context menu which version to use. You could use a batch file to set the paths for each version to ensure that each version only finds the correct python install and is blissfully unaware of the other one and then call start <idle> %1 on the last line... see how you go first, if you have any problems with the interpreter finding the other install make the shortcut into a batch file. – Michael Stimson Mar 31 '15 at 4:35
  • 1
    As a workaround that will do me fine. I'll upvote, accept, and only change my accept if someone comes along with a way to avoid that extra Send To click. Thanks! – PolyGeo Mar 31 '15 at 4:58
  • 3
    @PolyGeo Yes, it can be done without using Send To, but it is (can be) a bit more involved than this method as you have to do some Registry Editing. A right-click menu is known as a Context Menu. They make some editor utilities to modify them, and you can find a tutorial here. I'd post a full answer but I'm lazy and technically it's SuperUser territory. – Chris W Mar 31 '15 at 5:16
  • Thanks @ChrisW I followed the instructions at your tutorial link and was able to get precisely the Context Menu that I was after. – PolyGeo Mar 31 '15 at 5:33
2

My configuration is now using ArcGIS 10.4.1 for Desktop and ArcGIS Pro 1.3.

It looks like the installs of those two architectures now takes better care because when I right-click on a *.py file I am offered the choice to Edit with IDLE or to Edit with IDLE (ArcGIS Pro).

enter image description here

Edit with IDLE opens with Python 2.7.10:

enter image description here

Edit with IDLE (ArcGIS Pro) opens with Python 3.4.4:

enter image description here

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.