Permanently adding to the Python path in Ubuntu

David C. Ullrich dullrich at sprynet.com
Tue Sep 1 12:00:11 EDT 2009


When I wanted to set PYTHONPATH I had the advantage of
knowing nothing about how Linux/Ubuntu was supposed to work,
so I tried everything. ~/.profile worked for me.

In article <mailman.670.1251592772.2854.python-list at python.org>,
 Chris Colbert <sccolbert at gmail.com> wrote:

> I'm having an issue with sys.path on Ubuntu. I want some of my home
> built packages to overshadow the system packages. Namely, I have built
> numpy 1.3.0 from source with atlas support, and I need it to
> overshadow the system numpy 1.2.1 which I had to drag along as a
> dependency for other stuff. I have numpy 1.3.0 installed into
> /usr/local/lib/python2.6/dist-packages/. The issue is that this
> directory is added to the path after the
> /usr/lib/python2.6/dist-packages/ is added, so python doesnt see my
> version of numpy.
> 
> I have been combating this with a line in my .bashrc file:
> 
> export PYTHONPATH=/usr/local/lib/python2.6/dist-packages
> 
> So when I start python from the shell, everything works fine.
> 
> Problems show up when python is not executed from the shell, and thus
> the path variable is never exported. This can occur when I have
> launcher in the gnome panel or i'm executing from within wing-ide.
> 
> Is there a way to fix this so that the local dist-packages is added to
> sys.path before the system directory ALWAYS? I can do this by editing
> site.py but I think it's kind of bad form to do it this way. I feel
> there has to be a way to do this without root privileges.
> 
> Any ideas?
> 
> Cheers,
> 
> Chris

-- 
David C. Ullrich



More information about the Python-list mailing list