[Tutor] how to add directory to python search list

Surya P.K. Kasturi kasturisurya at gmail.com
Sun Jul 17 16:38:26 CEST 2011


Thanks a lot. your posts are really helpful.

On Sun, Jul 17, 2011 at 4:41 PM, Steven D'Aprano <steve at pearwood.info>wrote:

> Surya P.K. Kasturi wrote:
>
>  can you tell me in detail how to do this.
>> I am new to linux.
>>
>
> "this" being:
>
>  On Sat, Jul 16, 2011 at 11:48 AM, Alan Gauld <alan.gauld at btinternet.com>*
>> *wrote:
>>
>>> 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.
>>>
>>
> (Surya, on this list we prefer if people don't top-post.)
>
> What Alan means is for you to edit your login file so that it creates an
> environment variable. How you do that depends on which shell you are using.
> If you don't know which shell, try this:
>
> (1) Open a fresh terminal window.
> (2) Type "echo $SHELL" (without the quotation marks) and press Enter.
>
> This will print something like this:
>
>
> [steve at sylar ~]$ echo $SHELL
> /bin/bash
>
>
> So I am running "bash" as my shell. So I have the following line in my bash
> login file, .bashrc:
>
>
> export PYTHONPATH=/home/steve/python/
>
>
> That creates an environment variable, PYTHONPATH, which Python will
> automatically add to sys.path.
>
> (Other shells will do this differently.)
>
>
> Another alternative: I also have set a startup file:
>
>
> export PYTHONSTARTUP=/home/steve/**python/startup.py
>
>
> I can put any Python code I like in startup.py and it will be run just
> before the interactive interpreter.
>
> Or you can follow Peter's advice and use a .pth file.
>
>
>
> --
> Steven
>
>
> ______________________________**_________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor<http://mail.python.org/mailman/listinfo/tutor>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110717/331f89da/attachment.html>


More information about the Tutor mailing list