PYTHONPATH

Brian van den Broek broek at cc.umanitoba.ca
Sun Apr 23 19:05:28 EDT 2006


Edward Elliott said unto the world upon 23/04/06 04:28 PM:
> Brian van den Broek wrote:
> 
>>The suggestions above appear not to work for me:
>>
>>brian at Cedric:~$ cat /etc/profile | grep 'export PYTHONPATH'
>>export PYTHONPATH="~/PythonFiles"
>>brian at Cedric:~$ cat .bash_profile | grep 'export PYTHONPATH'
>>export PYTHONPATH="~/PythonFiles"
> 
> 
> Those files are only read when you start the shell.  I'm guessing you made 
> those changes from the currently running shell.  To fix it you have 3 choices:
> 1. Close the shell and start a new one
> 2. Type 'bash -l' at the prompt to invoke a new login shell
> 3. Type '. .bash_profile' to read the changes into your current shell

Edward,

thanks for the reply. I'm going to not worry about exposing my
ignorance in what follows :-)

I ought to have specified that I did indeed think to invoke a new
shell after I made the changes. However, trying (2) and (3) as you
specified shed some light.

Early on, (probably miss-)following something I read on the net, I'd put
a block into my .bash_profile that read:

if 1; then
     somestuff

Trying (3) gave
brian at Cedric:~$ . .bash_profile
bash: 1: command not found

Commenting out the bad block in .bash_profile, if I open a shell and 
things are somewhat better.

Only somewhat, as if I open a brand new shell:

brian at Cedric:~$ python
Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> from sys import path
 >>> path[0:3]
['', '/usr/lib/python24.zip', '/usr/lib/python2.4']
 >>>
brian at Cedric:~$ . .bash_profile
brian at Cedric:~$ python
Python 2.4.2 (#2, Sep 30 2005, 21:19:01)
[GCC 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> from sys import path
 >>> path[0:3]
['', '/home/brian/PythonFiles', '/usr/lib/python24.zip']
 >>>


So, it seems that I currently have to invoke '. .bash_profile'
manually with each new shell opened for this to have effect. (Trained 
by Bill, I even rebooted to be sure that the invocation of
'. .bash_profile' is needed.)
But, still it is closer :-)

I still haven't managed to coerce lines in /etc/profile exporting 
PYTHONPATH to have an effect.



<snip>

>>I don't know where to look for more information; I'm assuming that 
>>ubuntu isn't doing it the standard way bruno referred to above. Could 
>>some ubuntu user cast light, please?
> 
> 
> This information bruno gave is correct.  

I didn't mean to suggest bruno was wrong, but instead that perhaps
ubuntu was a distro falling under his phrase:

> but this may vary according to your distro and your shell

such that the instructions he gave would not work without
modification. Apologies if I gave a different impression.

<snip>


> You might want to google for "bash shell tutorial" and familiarize yourself 
> with how bash shells work.  It can be somewhat confusing at first, but it's 
> a very powerful way to interact with your system.

Thanks for the suggestions. With luck, I'll get the remaining issue
sorted. Thanks for the help,

Brian vdB




More information about the Python-list mailing list