Installing Python modules
We have several techniques to install a Python module or package:
We can write
setup.py
and use the distribution utilities module,distutils
, to install the package into Python'slib/site-packages
directory. See Distributing Python Modules.We can set the
PYTHONPATH
environment variable to include our packages and modules. We can set this temporarily in a shell, or we can set it more permanently by editing our~/.bash_profile
or the system's/etc/profile
. We'll take a look at this in a little more depth in the later section.We can include the
.pth
files to add directories to the import path. These files can be located in the local directory orlib/site-packages
to provide an indirect reference to a module or package. See thesite
module documentation in Python Standard Library for more information.The local directory is a package as well. It's always first on the
sys.path
list. When working on a simple one-module Python application, this is very handy. When working...