[Tutor] running multiple versions of python

Wayne Werner wayne at waynewerner.com
Sun Jan 13 05:35:16 CET 2013


On Thu, 10 Jan 2013, Fowler, Trent wrote:
> I am running Windows 7 and I've installed two versions of python, 3.3 and 2.7. Python 3.3 was the first version I installed and I was able to run scripts from the desktop (not the command line). I installed python 2.7 so that I could get numpy, scipy, and matplotlib down the road, but I found that all the scripts on my desktop defaulted to python 2.7. Since I coded in 3.3 this caused some issues.
>
> I was able to fix this by right clicking the script icon, browsing programs, navigating to the python 3.3 file in my C: drive, and selecting the idle inside that directory. But then I found I wasn't able to run those scripts with python 2.7 using the exact same procedure.
>
> Unfortunately I don't know command-line programming very much at all, and it seemed like most of what I've seen online is geared towards that as a solution. Ideally I'd like to specify which python I want to run a script from the desktop, or possibly while I'm editing the script.

I basically have this same setup. To make things work for me, I do this:

- Go to your Python 2 directory ( probably C:\Python2.7> ) and rename
   python.exe to python2.exe and pythonw.exe to pythonw2.exe

- Make sure that both your Python 2 directory and Python 3 directories are on
   your path. You do this by opening the Start Menu and typing "Path" - then hit
   enter. You should have an environment variable called PATH - if not, create a
   new one. You'll want to make sure that you have the paths to Python 3 and 2
   in there. Assuming you've got C:\Python3.3> and C:\Python2.7>, you'd want to
   have a path that contains C:\Python3.3;C:\Python2.7;

Now if you run a python script from cmd or powershell you should be able to do:

C:\some\path> python2 a_matplot_program.py

HTH,
Wayne


More information about the Tutor mailing list