Installing Python Packages

First we'll start with a bit of knowledge on python packages (if you know much about python you can probably skip this), there's a few ways to install typical python packages that use distutils/setuptools so it is available for other python code to use:

  1. install (well, copy) it into the site-packages dir of your python distribution, python install does this (as well as other things, some's also compile C code which the python code uses for example)

  2. unix-like systems only: add a symlink in the site-packages dir pointing at the package dir, this is what I do most of the time when hacking on my code in linux (easier to cd to ~/Projects/<projectname> instead of /usr/lib/python2.5/site-packages/<projectname> or doing the sudo python install dance (even though it's fairly simple) every time I modify it)

  3. Change the PYTHONPATH environment variable to include the directory with your package directory in, it's a : (or ; in windows) separated list of dirs that python package directories are in

for 2 or 3 if the package contains C code you might want to do something similar to python build_ext --inplace so they can be imported. also there might be additional things installing with python install does that you'll want to do manually, of course that's different depending on the package

for more details about installing packages that use distutils see

Note: this only applies to packages that use distutils or setuptools (most things with and for 2 or 3 have the same structure in the source as in what gets installed

InstallingPythonPackages (last edited 2008-02-05 05:46:29 by localhost)