Getting PYTHONPATH Right

When deploying your application, it is essential that it has access to all the necessary libraries and packages that it uses. If such libraries and packages were installed using the standard setup.py program, then you may only need to worry about the application itself being found by Python.

Running Adapters Directly

For those server environments where you can just run the adapter code (BaseHTTPRequestHandler, Twisted), you can choose to specify the PYTHONPATH on the command line when you run the code. Here is an example of this (using bash on GNU/Linux or UNIX distributions):

PYTHONPATH=.:examples/Common python examples/BaseHTTPRequestHandler/SimpleApp.py

Adapters Run by the Web Server

For those server environments where the Web server itself runs the adapter code (CGI, mod_python, WSGI), you may need to either configure the Web server to alter the PYTHONPATH, if possible, or to add some extra lines in the adapter code to change Python's sys.path variable. Here is an example of this:

sys.path.append("/home/paulb/Software/Python/WebStack/examples/Common")

Configuring PYTHONPATH in Java Servlet Containers

In servlet container deployments, all required libraries and packages are typically bundled with the application itself. Since this bundling process is usually very inconvenient, a script has been included in the tools/JavaServlet directory to make it slightly easier.

Configuring PYTHONPATH in Webware

Since Webware's WebKit runs as a separate process, it is possible to specify PYTHONPATH on the command line when you start that process. Here is an example of this (using bash on GNU/Linux or UNIX distributions):

cd WebKit
PYTHONPATH=/home/paulb/Software/Python/WebStack/examples/Common ./AppServer

Configuring PYTHONPATH in Zope

In Zope's etc/zope.conf file, path directives can be used to indicate the location of various resources. Here is an example of this:

path /home/paulb/Software/Python/WebStack/examples/Common