[Tutor] sys.path, managing modules and packages

Rikard Bosnjakovic rikard.bosnjakovic at gmail.com
Thu Apr 26 07:09:55 CEST 2007

On 4/26/07, Switanek, Nick <nswitanek at stanford.edu> wrote:

> Can someone help me better understand how I ought to manage the modules and
> packages that I download? I often find that I can't use the code I've just
> downloaded, despite putting it into Lib/site-packages. Often I've added the
> subdirectory path via sys.path.append, but this seems to go only one level
> down, whereas I thought that when trying to import something python would
> search all subdirectories of the directories in the sys.path. I'd be glad
> for some basic instruction on the steps I need to take between downloading
> code from sourceforge and importing the functions in my scripts or at the
> command line.

You can use the environment-variable $PYTHONPATH for localized modules
you download. I have for example PYTHONPATH=~/hacks/python/modules,
and I put all downloaded modules in there.

- Rikard - http://bos.hack.org/cv/

More information about the Tutor mailing list