2 versions of python on 1 machine

F

flupke

I searched with Google and on this newsgroups and i didn't find any info
regarding this. If there is more info, please redirect me to that info.

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.

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?

How can i do that?

Thanks,
Benedict
 
P

Peter Hansen

flupke said:
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
 
A

Aaron Bingham

flupke said:
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.

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?

How can i do that?

You need to put the path to the desired version in the PATH environment
variable. You shoudn't need to change PYTHONPATH at all.

--
 
F

flupke

Peter Hansen wrote:
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

I used the 2 batch files technique and removed c:\python23 from my
path var and all is fine now.
Where did you find more info on PYTHONHOME and PYTHONPATH because
the docs don't seem to contain a whole lot of info.

Thanks
Benedict
 
N

Nick Coghlan

More recent versions of Windows should allow you to use %* for "all the
arguments to the batch file".
Where did you find more info on PYTHONHOME and PYTHONPATH because
the docs don't seem to contain a whole lot of info.

I think PYTHONPATH is discussed in the tutorial. PYTHONHOME, I'm not so sure on
(PYTHONPATH and PYTHONSTARTUP are the only two you're likely to care about,
though - and I think the Tutorial covers both of them).

Cheers,
Nick.
 
P

Peter Hansen

flupke said:
I used the 2 batch files technique and removed c:\python23 from my
path var and all is fine now.
Where did you find more info on PYTHONHOME and PYTHONPATH because
the docs don't seem to contain a whole lot of info.

Typing "python -h" gives a good start. I'm sorry, I don't recall
where else there is useful info on those, though I'm pretty sure
Google could help. (I'm not sure there's much to add to what the
"-h" option tells you, however.)

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top