Where should I put my HTMLgen directory?

Jeff Kunce kuncej at mail.conservation.state.mo.us
Tue Jun 13 11:02:38 EDT 2000


> I have unpacked HTMLGen into:
> C:\Program Files\Python\Lib\HTMLgen
>
> But when I try to run:
> import HTMLgen
>
> I get the traceback:
> ...
> ImportError: No module named HTMLgen

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


  --Jeff





More information about the Python-list mailing list