2 versions of python on 1 machine

Peter Hansen peter at engcorp.com
Thu Jan 6 10:54:07 EST 2005


flupke wrote:
> I have version 2.3.4 and 2.4 installed on windows and i thought that by 
> switching the PYTHONPATH parameter to the dir of the 2.4 version that 
> that would make python 2.4 active.

That is not the purpose of PYTHONPATH.  I'd suggest removing
any definition of this environment variable that you have,
unless you have a specific reason to use it and know what it
actually does.  I believe the docs on it are fairly clear,
so reading them again might help.  Note that if you have installed
both versions of Python using the regular installer, the
PYTHONPATH information would be redundant anyway because
each version puts the necessary info in the Windows registry.

> However when i envoke python from the commandline, it still runs 2.3.4
> Is it possible to have 2 versions installed and switching versions when
> you need to?

It's quite possible.  It sounds like your problem is that you have
the c:\python23 folder in your PATH (note, not PYTHONPATH, just the
old DOS PATH variable).  If that's the case, you should probably
remove it and use batch files to invoke the different versions
instead.

> How can i do that?

On my machine, I have a folder called c:\bin where I put useful
batch files.  I have a python23.bat and a python24.bat file,
which basically just call c:\python23\python.exe or
c:\python24\python.exe as required.  For various reasons which
may or may not apply to you as well, I also have each of them
set the PYTHONHOME variable to point to the right folder
as well.

The content of each batch file is like this:
@echo off
c:\python23\python.exe %1 %2 %3 %4 %5 %6 %7 %8 %9

-Peter



More information about the Python-list mailing list