2.4 How installation works
Keywords: inst

##
2.4 How installation works

After the `build` command runs (whether you run it explicitly, or the `install` command does it for you), the work of the `install` command is relatively simple: all it has to do is copy everything under build/lib (or build/lib.plat) to your chosen installation directory.

If you don't choose an installation directory--i.e., if you just run `setup.py install`--then the `install` command installs to the standard location for third-party Python modules. This location varies by platform and by how you built/installed Python itself. On Unix and Mac OS, it also depends on whether the module distribution being installed is pure Python or contains extensions (``non-pure''):

Platform | Standard installation location | Default value | Notes
--- | --- | --- | ---
Unix (pure) | prefix/lib/python2.0/site-packages | /usr/local/lib/python2.0/site-packages | (1)
Unix (non-pure) | exec-prefix/lib/python2.0/site-packages | /usr/local/lib/python2.0/site-packages | (1)
Windows | prefix | C:\Python | (2)
Mac OS (pure) | prefix:Lib | Python:Lib ** ??? ** |
Mac OS (non-pure) | prefix:Mac:PlugIns | Python:Mac:PlugIns** ??? ** |

Notes:

(1)
  Most Linux distributions include Python as a standard part of the system, so prefix and exec-prefix are usually both /usr on Linux. If you build Python yourself on Linux (or any Unix-like system), the default prefix and exec-prefix are /usr/local.
(2)
  The default installation directory on Windows was C:\Program Files\Python under Python 1.6a1, 1.5.2, and earlier.

prefix and exec-prefix stand for the directories that Python is installed to, and where it finds its libraries at run-time. They are always the same under Windows and Mac OS, and very often the same under Unix. You can find out what your Python installation uses for prefix and exec-prefix by running Python in interactive mode and typing a few simple commands. Under Unix, just type `python` at the shell prompt; under Windows, run ``Python 2.0 (interpreter)'' ** right? **; under Mac OS, ** ??? **. Once the interpreter is started, you type Python code at the "`»>` " prompt. For example, on my Linux system, I type the three Python statements shown below, and get the output as shown, to find out my prefix and exec-prefix:

      Python 1.5.2 (#1, Apr 18 1999, 16:03:16)  [GCC pgcc-2.91.60 19981201 (egcs-1.1.1  on linux2
      Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
      >>> import sys
      >>> sys.prefix
      '/usr'
      >>> sys.exec_prefix
      '/usr'

If you don't want to install to the standard location, or if you don't have permission to write there, then you need to read about alternate installations in the next section.