How does mod_python know where's Python installed ?

Graham Dumpleton Graham.Dumpleton at gmail.com
Tue Jun 12 19:48:32 EDT 2007


On Jun 13, 7:03 am, arorap <aro... at gmail.com> wrote:
> Hi,
>
> I recently setupmod_pythonsuccessfully and things work smooth.
> However, I do not remember tellingmod_pythonwhere to find Python
> installation. There's not environment variable which gives that
> information. As such how doesmod_pythonknow where to find Python ?
> When I print sys.path in my scripts it contains my python installation
> folder. I'm wondering how does Apache/mod_pythonget this
> information ?
>
> I'm running Apache 2.2 on windows.

Rather than duplicate here, for a long explanation see the comments in
the file:

  Modules/getpath.c

in the Python source code.

In short though, it searches for 'python' executable on PATH and from
that tries to determine where the corresponding 'lib' directory is for
the version of Python that mod_python is linked against.

Because it looks in PATH, this will not always work when people have
multiple versions of Python installed on their system with different
base directories. See:

  https://issues.apache.org/jira/browse/MODPYTHON-225

for further details in respect of that problem.

Graham





More information about the Python-list mailing list