[mod_python] Setting the python executable

Graham Dumpleton graham.dumpleton at gmail.com
Thu Apr 10 18:37:37 EDT 2008


2008/4/11 Evert Rol <evert.rol at gmail.com>:
>   Hi all,
>
>  I'm having a hard time telling Apache (or mod_python) to tell which python
> executable to use.
>  The thing is, I don't have a root access, so I'm running the Apache server
> and python 2.5 under my user account. Both have also been installed this
> way, ie, they are in my in the directory tree of my user account.
>  To avoid interference with the older system python (2.3), I just call
> python with the full path (I try to avoid changing my path, since some of
> these scripts run as cron jobs, bypassing a lot of setup files).
>  Bit of debugging (eg, print sys.executable in a mod_python script) showed,
> however, that mod_python is still happily using the system python, not my
> locally installed. That goes fine up to a certain point, but it does of
> course crash in the end. I had compiled mod_python with the --with-python
> and --with-apxs options, but looks like that doesn't help here.
>  After some further searching around, I came across the Action directive for
> Apache; still didn't work, although that may be simply because I did that
> incorrectly.
>
>  For the record, I'm using mod_python for Django, maing things potentially
> more convoluted.
>  Here's what my latest attempt at getting this to work (still failing after
> plenty of Apache restarts):
>
>  Action thepython-program /home/evert/sw/bin/python2.5
>  # Django directory
>  <Location "/testing/">
>     SetHandler thepython-program
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE mysite.settings
>     PythonDebug On
>  </Location>
>
>
>  I'm beginning to run out of ideas (& Google search terms). Does anyone have
> any pointers?

The mod_python module embeds the Python interpreter and so it can only
use the version you compiled it against, Your attempts therefore to
use Action are fruitless in that respect, but also because that isn't
what the Action directive is for.

Please clarify which version of mod_python you are using and which
version of Python it was actually compiled against. If using
mod_python 3.3.1 you should see warning/error messages in Apache error
log on startup when the version of Python that it was compiled against
was in a non standard location on path of Apache user and thus
couldn't be found. This though would generally result in complete
failure, yet you suggest it works for a bit and fails which suggests
that mod_python isn't compiled against version of Python you want and
it is your Python code which is incompatible with the version of
Python that mod_python was compiled for.

Also see:

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

Graham


More information about the Mod_python mailing list