[Tutor] how to add directory to python search list

ALAN GAULD alan.gauld at btinternet.com
Sun Jul 17 23:36:23 CEST 2011


It depends on what shell you are using.

Most beginners use the Bash shell and for that you need to open your 
.bash_profile (or .bashrc, I can't recall the preferred one for env vars...)
and add a line like:

export PYTHONPATH=$PYTHONPATH:/path/to/my/python/modules

Next time you login Python should find your modules OK.

HTH

 Alan Gauld
Author of the Learn To Program website
http://www.alan-g.me.uk/





________________________________
From: Surya P.K. Kasturi <kasturisurya at gmail.com>
To: Alan Gauld <alan.gauld at btinternet.com>
Cc: Tutor at python.org
Sent: Sunday, 17 July, 2011 7:45:08
Subject: Re: how to add directory to python search list

Mr. Gauld 

can you tell me in detail how to do this.
I am new to linux.


On Sat, Jul 16, 2011 at 11:48 AM, Alan Gauld <alan.gauld at btinternet.com> wrote:

Surya P.K. Kasturi wrote:
>
>OS : Ubuntu Linux
>>Python Version : 2.6.4
>>
>>I have some third party modules to be installed in my computer.
>>So, I want to add the module directory to python search list.
>>
>>I used :
>>
>>*>>> import sys*
>>*>>> sys.path.append('directory address')*
>>*
>>*
>>this could do my work but as soon as I close the terminal and reopen it, I
>>

You need to add the folder to your PYTHONPATH environment variable.
>You usually do this your .login or .profile file.
>
>Python will add the contents of PYTHONPATH to sys.path on startup.
>
>HTH,
>
>
>Alan G
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110717/0ad81d71/attachment.html>


More information about the Tutor mailing list