setting PYTHONPATH to override system wide site-packages

Carl Banks pavlovevidence at
Sun Mar 1 05:24:17 CET 2009

On Feb 28, 7:30 pm, per <perfr... at> wrote:
> hi all,
> i recently installed a new version of a package using python
> install --prefix=/my/homedir on a system where i don't have root
> access. the old package still resides in /usr/lib/python2.5/site-
> packages/ and i cannot erase it.
> i set my python path as follows in ~/.cshrc
> setenv PYTHONPATH /path/to/newpackage
> but whenever i go to python and import the module, the version in site-
> packages is loaded. how can i override this setting and make it so
> python loads the version of the package that's in my home dir?

What happens when you run the command "print sys.path" from the Python
prompt?  /path/to/newpackage should be the second item, and shoud be
listed in front of the site-packages dir.

What happens when you run "print os.eviron['PYTHONPATH']" at the
Python interpreter?  It's possible that the sysadmin installed a
script that removes PYTHONPATH environment variable before invoking
Python.  What happens when you type "which python" at the csh prompt?

What happens when you type "ls /path/to/newpackage" at your csh
prompt?  Is the module you're trying to import there?

You approach should work.  These are just suggestions on how to
diagnose the problem; we can't really help you figure out what's wrong
without more information.

Carl Banks

More information about the Python-list mailing list