Multiple versions of python

Scott David Daniels Scott.Daniels at Acm.Org
Tue Jul 21 10:17:13 EDT 2009


ChrisW wrote:
> Hi,
> 
> I have installed 2 versions of python on my Windows XP computer - I
> originally had 3.0.1, but then found that the MySQL module only
> supported 2.*, so I've now installed that.  I have found that if I
> change the Windows Environment Variable path, then I can change the
> version of python called when I type 'python' into a command line.
> However, I'd like to be able to choose which version I use.  I know
> that if I change C:\Python26\python.exe to
> C:\Python26\python2.exe and C:\Python30\python.exe to C:
> \Python26\python3.exe, then typing 'python2' or 'python3' will invoke
> the correct interpreter.  However, is it safe just to rename the
> executable files? Is there a more elegant way to achieve the same
> task?
I wouldn't rename them.  You can, of course, copy them (so you have two
executables), or you can pick a somedir on your path (I made a directory
"C:\cmds" that I add to my path, but tastes vary).

C:> copy con <somedir>\py25.cmd
C:\Python25\python\python.exe %*
^Z
C:> copy con <somedir>\py31.cmd
C:\Python31\python\python.exe %*
^Z

I'd use the two-digit form, as that is where interface changes
happen; trying code with py24, py25, py26 can be convenient.
By the way, install Python 3.1 rather than 3.0; think of 3.0 as the
alpha of the 3.X branches (it will get no love at all now that 3.1
is out).

--Scott David Daniels
Scott.Daniels at Acm.Org



More information about the Python-list mailing list