How do I configure my system so that Windows Python 2.7 CGI scripts see user-defined packages?
Question: I have a Python script that uses some of my own packages in my own library
which is stored in a non-standard folder: k:\lib. When running the script from
the command-line the interpreter can find my packages because I have set the
PYTHONPATH environment variable.

However, when running the script as a CGI script, the environment variable
does not seem to be read, so my question is what can I do about this?

One solution I read was to put

    
    
    import sys
    sys.path.append( 'k:\\lib' )
    

at the top of my script but this doesn't work - the next line in my script is

    
    
    import site_consts
    

where site_consts is in k:\lib but I get the error message "no module named
site_consts".

Not sure if this is Python problem or a Windows or an Apache one.


Answer: You could add a `name.pth` file to one of the four directories described
[here](http://docs.python.org/2/library/site.html#module-site) in the
documentation.

