2 versions of python on 1 machine

Discussion in 'Python' started by flupke, Jan 6, 2005.

  1. flupke

    flupke Guest

    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
    flupke, Jan 6, 2005
    #1
    1. Advertising

  2. flupke

    Peter Hansen Guest

    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
    Peter Hansen, Jan 6, 2005
    #2
    1. Advertising

  3. 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.
    >
    > 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.

    --
    --------------------------------------------------------------------
    Aaron Bingham
    Application Developer
    Cenix BioScience GmbH
    --------------------------------------------------------------------
    Aaron Bingham, Jan 6, 2005
    #3
  4. flupke

    flupke Guest

    Peter Hansen wrote:
    <snip>
    >
    > 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
    flupke, Jan 7, 2005
    #4
  5. flupke

    Nick Coghlan Guest

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


    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.

    --
    Nick Coghlan | | Brisbane, Australia
    ---------------------------------------------------------------
    http://boredomandlaziness.skystorm.net
    Nick Coghlan, Jan 7, 2005
    #5
  6. flupke

    Peter Hansen Guest

    flupke wrote:
    > 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
    Peter Hansen, Jan 8, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. manny
    Replies:
    2
    Views:
    368
    William LaMartin
    Mar 30, 2006
  2. flupke
    Replies:
    1
    Views:
    323
    Peter Hansen
    Jan 12, 2005
  3. Replies:
    2
    Views:
    3,849
    Fuzzyman
    Feb 24, 2006
  4. johnny
    Replies:
    5
    Views:
    495
    Antonio Cuni
    Jul 11, 2007
  5. Gabor Urban

    More Python versions on an XP machine

    Gabor Urban, Nov 14, 2009, in forum: Python
    Replies:
    3
    Views:
    287
    Nobody
    Nov 15, 2009
Loading...

Share This Page