query python env

Discussion in 'Python' started by David Bear, Jan 14, 2005.

  1. David Bear

    David Bear Guest

    How does one query the python environment, ie pythonhome, pythonpath,
    etc.

    also, are there any HOWTO's on keeping multiple versions of python
    happy?
     
    David Bear, Jan 14, 2005
    #1
    1. Advertising

  2. David Bear wrote:
    > How does one query the python environment, ie pythonhome


    sys.prefix

    > pythonpath


    sys.path

    > etc.


    sys.etc

    > also, are there any HOWTO's on keeping multiple versions of python
    > happy?


    I think it is sufficiently trivial that none is needed. Just make sure
    the distributions are installed in different directories.

    What problems are you having?
    --
    Michael Hoffman
     
    Michael Hoffman, Jan 14, 2005
    #2
    1. Advertising

  3. David Bear

    Steve Holden Guest

    Michael Hoffman wrote:

    > David Bear wrote:
    >
    >> How does one query the python environment, ie pythonhome

    >
    >
    > sys.prefix
    >
    > > pythonpath

    >
    > sys.path
    >
    >> etc.

    >
    >

    [...]
    I suspect rather that the OP is looking for os.environ, as in:

    [sholden@headrat sholden]$ ENVAR=value
    [sholden@headrat sholden]$ export ENVAR
    [sholden@headrat sholden]$ python
    Python 2.2.1 (#1, Aug 30 2002, 12:15:30)
    [GCC 3.2 20020822 (Red Hat Linux Rawhide 3.2-4)] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import os
    >>> os.environ["ENVAR"]

    'value'


    regards
    Steve
    --
    Steve Holden http://www.holdenweb.com/
    Python Web Programming http://pydish.holdenweb.com/
    Holden Web LLC +1 703 861 4237 +1 800 494 3119
     
    Steve Holden, Jan 14, 2005
    #3
  4. David Bear wrote:
    > How does one query the python environment, ie pythonhome, pythonpath,
    > etc.
    >
    > also, are there any HOWTO's on keeping multiple versions of python
    > happy?


    In general, (and in this case) the answer is system-specific.
    You need to explain (A) what operating system, and (B) what you
    mean by multiple Python versions.

    For example, for Windows 2K/XP, As long as you try for only
    distinct major versions (2.2.x, 2.3.x, 2.4.x). There should
    not be a problem. The primary issues are where (and how) does
    your system get to the python files.


    --Scott David Daniels
     
    Scott David Daniels, Jan 14, 2005
    #4
  5. Steve Holden wrote:
    > I suspect rather that the OP is looking for os.environ, as in:


    He was using the examples of PYTHONHOME and PYTHONPATH which have
    specific meanings. Using sys.prefix is better than
    os.environ["PYTHONHOME"], which is unlikely to be set.
    --
    Michael Hoffman
     
    Michael Hoffman, Jan 15, 2005
    #5
    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. Adriano Ferreira
    Replies:
    9
    Views:
    580
    Mike Meyer
    Dec 3, 2005
  2. John Salerno
    Replies:
    30
    Views:
    1,970
    Stephan Kuhagen
    Aug 10, 2006
  3. Ankit Mehta
    Replies:
    1
    Views:
    1,439
    Simon Brooke
    Sep 29, 2006
  4. Yves Dorfsman

    #!/usr/bin/env python vs. #!/usr/bin/python

    Yves Dorfsman, May 2, 2008, in forum: Python
    Replies:
    27
    Views:
    2,011
    Tim Roberts
    May 10, 2008
  5. TDR
    Replies:
    3
    Views:
    180
    Daniel Berger
    Aug 31, 2007
Loading...

Share This Page