Table Of Contents

Previous topic

Deploying your TG application with an Egg and Easy Install

Next topic

Running TurboGears Behind Apache

How to Install TurboGears Without root Privileges

When you install TurboGears on a Unix-like system (including Mac OS X), using the standard procedure with, you will need root privileges to install the Python packages to the system-wide Python site-packages directory and scripts to /usr/local/bin. This may not be desirable or possible for everybody.

It’s easy to tell to install TurboGears below your home directory instead, so you don’t need to be root or use sudo. There are several methods to achieve this. Two of them are explained on this page.

Method Two: Using pydistutils.cfg


Warning: Setting up things as explained in this section will affect all future installations of Python packages through distutils or easy_install, i.e. they will be installed under your home directory as well. If you don’t want this, remove or rename the .pydistutils.cfg file after installing TurboGears.

Setting up Installation Locations

When you install Python packages either with easy_install or by running “python install” from the package distribution, the procedure will look for a per-user configuration file under the path ~/.pydistutils.cfg (the path is different on Windows, but that does not concern us here).

You may specify several options in this configuration file, which will affect the install locations. You can use these to point to a Python library directory below your home directory. We recommend the following locations:

Mac OS X
Packages: ~/Library/Python/X.Y/lib
Scripts: ~/bin
Data: ~/Library/Python/X.Y/lib
C Headers: ~/Library/Python/X.Y/include
Packages: ~/lib/pythonX.Y
Scripts: ~/bin
Data: ~/lib/pythonX.Y
C Headers: ~/include/pythonX.Y

Here is an example for the contents of a .pydistutils.cfg file for a Linux system:

install_lib = ~/lib/python$py_version_short/
install_data = ~/lib/python$py_version_short/
install_headers = ~/include/python$py_version_short/
install_scripts = ~/bin

The $py_version_short placeholder will get replaced with the version of the Python interpreter, which you use to run the installation command (omitting anything behind the minor version number, e.g. 2.5). Make sure you create all installation directories before proceeding.

You can find out the complete list of options for any distutils command or easy_install using the –help option, e.g.:

$ python <command> --help


$ easy_install --help

Also, see “References” below for a link to the distutils documentation.


Next, you must make sure, that the Python interpreter will find the packages in your library directory. To check the current Python module search path, do:

$ python -c "import sys; print sys.path"

If your library directory is not included in the output, you have to set the PYTHONPATH environment variable, for example:

$ export PYTHONPATH="$HOME/lib/python2.5"

(Substitute 2.5 with the appropriate version number for your Python installation.)

To make this setting permanent, add the line above (without the leading $) to your ~/.profile or ~/.bash_profile file. Please also check your system documentation on how to make environment variable settings permanent.

Setting PATH

Make sure that the install location for Python scripts is on your command search path, by adding it to the PATH environment variable:

$ export PATH="$HOME/bin:$PATH"

Make this setting permanent the same way you did for the PYTHONPATH variable.

Installing TurboGears

Finally, install TurboGears as usual by downloading [1] & running

$ wget
$ python --script-dir=$HOME/bin