query python env

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • David Bear

    #1

    query python env

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

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

    #2
    Re: query python env

    David Bear wrote:[color=blue]
    > How does one query the python environment, ie pythonhome[/color]

    sys.prefix
    [color=blue]
    > pythonpath[/color]

    sys.path
    [color=blue]
    > etc.[/color]

    sys.etc
    [color=blue]
    > also, are there any HOWTO's on keeping multiple versions of python
    > happy?[/color]

    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

    Comment

    • Scott David Daniels

      #3
      Re: query python env

      David Bear wrote:[color=blue]
      > How does one query the python environment, ie pythonhome, pythonpath,
      > etc.
      >
      > also, are there any HOWTO's on keeping multiple versions of python
      > happy?[/color]

      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.Daniels@A cm.Org

      Comment

      • Steve Holden

        #4
        Re: query python env

        Michael Hoffman wrote:
        [color=blue]
        > David Bear wrote:
        >[color=green]
        >> How does one query the python environment, ie pythonhome[/color]
        >
        >
        > sys.prefix
        >[color=green]
        > > pythonpath[/color]
        >
        > sys.path
        >[color=green]
        >> etc.[/color]
        >
        >[/color]
        [...]
        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.[color=blue][color=green][color=darkred]
        >>> import os
        >>> os.environ["ENVAR"][/color][/color][/color]
        '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

        Comment

        • Michael Hoffman

          #5
          Re: query python env

          Steve Holden wrote:[color=blue]
          > I suspect rather that the OP is looking for os.environ, as in:[/color]

          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

          Comment

          Working...