newbie question about PYTHONPATH

Discussion in 'Python' started by Tim Hanson, Feb 15, 2011.

  1. Tim Hanson

    Tim Hanson Guest

    I am to the point in _Learning_Python_ where functions are introduced.

    I decided to experiment by putting a function into a file and importing it
    into Idle. Of course, Idle couldn't find it, so I executed the following
    command in Bash:

    PYTHONPATH=/home/foo/prog/learning_python
    export PYTHONPATH
    env | grep PYTHONPATH

    ~$PYTHONPATH=/home/foo/prog/learning_python

    Idle still won't find it. I'm doing something wrong?
    Tim Hanson, Feb 15, 2011
    #1
    1. Advertising

  2. Tim Hanson

    Doug Epling Guest

    The best way I have found is to place that definition of your PYTHONPATH
    in your .bash_profile in your home directory and export it from there.

    PYTHONPATH=/home/foo/prog/learning_python

    export PYTHONPATH

    This way your PYTHONPATH is picked up each time you log on. You
    might have to restart IDLE for the changes you mention below to take effect.


    On 2/15/2011 12:49 PM, Tim Hanson wrote:
    > I am to the point in _Learning_Python_ where functions are introduced.
    >
    > I decided to experiment by putting a function into a file and importing it
    > into Idle. Of course, Idle couldn't find it, so I executed the following
    > command in Bash:
    >
    > PYTHONPATH=/home/foo/prog/learning_python
    > export PYTHONPATH
    > env | grep PYTHONPATH
    >
    > ~$PYTHONPATH=/home/foo/prog/learning_python
    >
    > Idle still won't find it. I'm doing something wrong?
    Doug Epling, Feb 19, 2011
    #2
    1. Advertising

  3. Il giorno 19/feb/2011, alle ore 18.25, Doug Epling ha scritto:

    > The best way I have found is to place that definition of your PYTHONPATH in your .bash_profile in your home directory and export it from there.
    >
    > PYTHONPATH=/home/foo/prog/learning_python
    >
    > export PYTHONPATH
    >
    > This way your PYTHONPATH is picked up each time you log on. You might have to restart IDLE for the changes you mention below to take effect.


    Yes but like this you overwrite it
    export PYTHONPATH=/your/path:$PYTHONPATH

    is much more safe to use
    Andrea Crotti, Feb 19, 2011
    #3
  4. On Sat, 2011-02-19 at 19:22 +0100, Andrea Crotti wrote:
    > Il giorno 19/feb/2011, alle ore 18.25, Doug Epling ha scritto:
    >
    > > The best way I have found is to place that definition of your PYTHONPATH in your .bash_profile in your home directory and export it from there.
    > >
    > > PYTHONPATH=/home/foo/prog/learning_python
    > >
    > > export PYTHONPATH
    > >
    > > This way your PYTHONPATH is picked up each time you log on. You might have to restart IDLE for the changes you mention below to take effect.

    >
    > Yes but like this you overwrite it
    > export PYTHONPATH=/your/path:$PYTHONPATH
    >
    > is much more safe to use

    It's even safer to use
    export PYTHONPATH=$PYTHONPATH:/your/path
    Westley Martínez, Feb 19, 2011
    #4
    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. Harald Kirsch

    jython and PYTHONPATH

    Harald Kirsch, Jun 28, 2003, in forum: Python
    Replies:
    1
    Views:
    1,272
    Ype Kingma
    Jun 30, 2003
  2. vincent delft

    CGIHTTPserver looze PYTHONPATH

    vincent delft, Jul 13, 2003, in forum: Python
    Replies:
    1
    Views:
    452
    vincent_delft
    Jul 13, 2003
  3. klappnase

    Re: Python..Tkinter..PYTHONPATH..

    klappnase, Jul 30, 2003, in forum: Python
    Replies:
    0
    Views:
    399
    klappnase
    Jul 30, 2003
  4. Eduardo Suarez

    newbie, help with pythonpath

    Eduardo Suarez, Mar 3, 2005, in forum: Python
    Replies:
    4
    Views:
    746
    Eduardo Suarez
    Mar 4, 2005
  5. Mark Fink

    Jython Pythonpath question

    Mark Fink, Feb 21, 2006, in forum: Python
    Replies:
    1
    Views:
    451
    Kent Johnson
    Feb 21, 2006
Loading...

Share This Page