FAQ
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?

Search Discussions

  • Panupat Chongstitwattana at Feb 15, 2011 at 6:12 pm
    I think the command line should look something along this line

    export PYTHONPATH=$HOME/foo/prog/learning_python/:

    with a colon at the end.
    On Wed, Feb 16, 2011 at 12:49 AM, 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?
    --
    http://mail.python.org/mailman/listinfo/python-list
  • Alexander Kapps at Feb 15, 2011 at 7:05 pm
    On 15.02.2011 19:12, Panupat Chongstitwattana wrote:

    Panupat, please don't top-post, it messes the the natural order of
    the discussion. Thanks.
    I think the command line should look something along this line

    export PYTHONPATH=$HOME/foo/prog/learning_python/:

    with a colon at the end.
    Nope, the colon is only needed as a delimiter if you give more than
    one file.
    On Wed, Feb 16, 2011 at 12:49 AM, Tim Hansonwrote:
    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?
    $ export PYTHONPATH=~/src/python/
    $ idle

    works fine here. Where are you setting PYTHONPATH and from where do
    you run idle? If you set it in a terminal window, but run idle from
    a Desktop menu it won't work as exporting environment variables does
    only affect sub-processes. You might want to set PYTHONPATH in your
    ~/.bash_profile and then re-login.

    Also, how do you name your file? A Python module must end in .py


    HTH
  • Doug Epling at Feb 19, 2011 at 5:25 pm
    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?
  • Andrea Crotti at Feb 19, 2011 at 6:22 pm

    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
  • Westley Martínez at Feb 19, 2011 at 7:00 pm

    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedFeb 15, '11 at 5:49p
activeFeb 19, '11 at 7:00p
posts6
users6
websitepython.org

People

Translate

site design / logo © 2022 Grokbase