newbie question about PYTHONPATH

Alexander Kapps alex.kapps at
Tue Feb 15 20:05:18 CET 2011

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 Hanson<tjhanson at>  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?

$ 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


More information about the Python-list mailing list