RESOLVED Re: PYTHONPATH

Brian van den Broek broek at cc.umanitoba.ca
Mon Apr 24 18:51:19 EDT 2006


Hi all,

As a fairly new linux user running ubuntu 5.10 I'd had problems 
persistently setting my PYTHONPATH environment variable. bruno and 
Edward got me most of the way (thanks!); I'm posting what worked for 
future googling.

bruno at modulix said unto the world upon 20/04/06 08:38 AM:

 >>Can anyone help me to make my path persistant?
 >
 >
 > Just like any other environnement variable on your system. With most
 > distros, it will be something like adding the line:
 >
 > export PYTHONPATH="/a/possible/path;/another/one;/and/a/third"
 >
 > either in /etc/profile (will be system-wide default) or ~/.bash_profile
 > (will be user-specific).

and


Edward Elliott said unto the world upon 23/04/06 07:56 PM:
> Brian van den Broek wrote:

<snip>

>>So, it seems that I currently have to invoke '. .bash_profile'
>>manually with each new shell opened for this to have effect. 
> 
> 
> Your shell must not be opening as a login shell.  From the bash man page:

<snip>

> "When an interactive shell that is not a login shell  is  started,  bash
> reads  and  executes  commands  from /etc/bash.bashrc and ~/.bashrc, if
> these files exist."
> 

So, to get the terminal ubuntu launches when you click on the panel's 
terminal icon to have a customized PYTHONPATH, one must, as Edward 
said, modify ~/.bashrc or link it with ~/.bash_profile.

The syntax that worked for me was *almost* what bruno suggested. It 
didn't work here until I used ':' rather than bruno's ';' as the path 
element separator. So, the lines

PYTHONPATH="/home/brian/FirstDir:/home/brian/SecondDir"
export PYTHONPATH

added to ~.bashrc make the terminal launched from the panel icon 
include /home/brian/FirstDir and /home/brian/SecondDir right after pwd 
in sys.path as desired.

Thanks Edward and bruno!

Best,

Brian vdB



More information about the Python-list mailing list