Entry
Where should I put my HTMLgen directory?
How do I add a path to sys.path?
Jun 16th, 2000 01:05
unknown unknown, Jeff Kunce
When you do an "import" python looks for the module in all the
directories in sys.path
Below are four ways to let python know where you have installed HTMLgen.
I use #4 myself.
1) Add the directory to sys.path in your program before you import the
module:
import sys
sys.path.append('C:\\Program Files\\Python\\Lib\\HTMLgen')
2) Add the directory to your systems "PYTHONPATH" environment
variable before you start your program. For windows:
SET PYTHONPATH=C:\Program Files\Python\Lib\HTMLgen
or if PYTHONPATH is already defined:
SET PYTHONPATH=C:\Program Files\Python\Lib\HTMLgen;%PYTHONPATH%
3) Create a file 'C:\\Program Files\\Python\\HTMLgen.pth' containing the
single line: Lib/HTMLgen
4) Import HTMLgen as a package
a) create an empty file C:\\Program
Files\\Python\\Lib\\HTMLgen\__init__.py
b) in your program, import HTMlgen like this:
from HTMLgen import HTMLgen
All these procedures are explained in the documentation, and in the
various python books. None is specific to HTMLgen.
And, personally, I would not put HTMLgen in the 'Lib' directory - I
think of that as modules that are distributed with python, and may get
overwritten with a new release. I'd suggest installing it as
C:\Program Files\Python\local\HTMLgen
or just
C:\Program Files\Python\HTMLgen