the correct way to install python packages as non root user in non default path

News123 news123 at
Tue Apr 21 00:32:47 CEST 2009


I'm having an Ubuntu host, but want to (experimentally)
install some modules, which are newer than the Ubuntu ones
(distros lag always a little behind and some tools need newer versions.)

What would be a clean way to do this?
I want to be sure, that any 'special hacks' on my host are cleanly
separated from the default installation.

I thought about installing some newer packets for example under
/opt/newpymods  # or any other name
and change the python path such, that modules will first be searched
there and only then in the default path.

Is this a viable approach?

How exactly would I have to set PYTHONPATH?

I'm asking, as I had some problems installing a new version of coherence.

What I did:

##### download a newer version of Coherence
cd /downloads
svn co Coherence

#### create a new directory for all 'newer' python modules
mkdir -p /opt/newpymod
export PYTHONPATH=/opt/newpymod
python install --prefix /opt/newpymod
### this fails, so I'll adapt PYTHONPATH
export PYTHONPATH=/opt/newpymod/lib/python2.5/site-packages
mkdir -p /opt/newpymod/lib/python2.5/site-packages
### now I get quite some error messages

> running install
> running bdist_egg
> running egg_info
> writing requirements to Coherence.egg-info/requires.txt
> writing Coherence.egg-info/PKG-INFO
> writing top-level names to Coherence.egg-info/top_level.txt
> writing dependency_links to Coherence.egg-info/dependency_links.txt
> writing entry points to Coherence.egg-info/entry_points.txt
> package init file 'misc/' not found (or not a regular file)
> Traceback (most recent call last):
>   File "", line 124, in <module>
>     setup(**setup_args)
>   File "/usr/lib/python2.5/distutils/", line 151, in setup
> . . .

thanks in advance for any help

More information about the Python-list mailing list