Installing Python modules
We have several techniques to install a Python module or package:
We can write
setup.pyand use the distribution utilities module,distutils, to install the package into Python'slib/site-packagesdirectory. See Distributing Python Modules.We can set the
PYTHONPATHenvironment 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_profileor 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
.pthfiles to add directories to the import path. These files can be located in the local directory orlib/site-packagesto provide an indirect reference to a module or package. See thesitemodule documentation in Python Standard Library for more information.The local directory is a package as well. It's always first on the
sys.pathlist. When working on a simple one-module Python application, this is very handy. When working...