473,383 Members | 1,762 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

installing mod_python -- sharing experiences

i would like to briefly share my experiences with
installing mod_python on a w2000 box. i must say that i
believe the installation process to be unnecessarily
complicated by the simple fact that the installer itself
seems to be buggy -- in my case, no combination of
mod_python 3.0.4, 3.1.2b and python 2.2.3, 2.3.3 ever
came to completion. rather, the installer would exit --
after an initial declaration of having successfully
found python in the registry -- with the words that it
'could not load python'. i now believe this may be due
to python being absent from ``path`` and a missing value
in ``pythonhome`` (see below), but on the other hand,
all my other package installations with this particular
installer brand had never given me any troubles. it
would be a nice thing if the installer was smart enough
to dispense some hints in such a case.

it is important to check that the correct python version
is selected for the respective version of mod_python --
as far as i can see, both 3.0.4 and 3.1.2b are built for
python 2.3, which at least in the former case is not so
clear from descriptions or filenames. whatever version
you downloaded, you can quickly check this by 1)
unpacking the ``*.exe`` file with a zip tool, 2) go to
the contained folder ``DATA``, open the binary
``mod_python.so`` in any text editor, and 3) search for
the string ``python2``. this should yield a single hit,
from which you can glean the expected version of the
python dll. since i never managed to finish the
installation process with the installer, i think it is
the best idea to then proceed like this:
1) simply grab that ``python_mod.so`` file and drop it
in the ``apache/modules`` folder; likewise, go to the
directory ``PURELIB/mod_python`` in the executable
archive and copy it as ``python/Lib/site-
packages/mod_python``.
2) in apaches ``httpd.conf``, do a test configuration
like this::

# NB.: When setting an alias, both the alias
# and the aliased location should end in a
# slash or avoid it.

Alias /mod_python0 "drive:/some/path/mod_python/test0"

<Directory "drive:/some/path/mod_python/test0">
Options Indexes
AddHandler python-program .py
PythonHandler myhandler
PythonDebug On
</Directory>

observe that ``.py`` does start with a dot -- this does
not seem to be essential, though.

one important point is that you had better make sure
that python scripts are not declared as cgi scripts in a
parent directory. if you absolutely need this, try
later, but for the moment it is important to understand
that the ``ExecCGI`` and the ``python-program``
declarations are enemies. -- restart apache (must be
version 2, btw, afaics), either from the services
management console, or, much better, from a terminal
window by saying

apache.exe -k restart

(if you have your apache installed as a service). the
terminal window method has the distinct advantage that
any error messages due to problems with the httpd.conf
do appear right in front of your eyes, instead of being
silently swallowed by the system. of course, you can
also simply start apache as an ordinary program with a
line like ::

apache -w -f drive:\path\to\apache\conf\httpd.conf
3) create .../mod_python/test0/myhandler.py and make
it contain something like this::

#
# -*- coding: utf-8 -*-

from mod_python import apache

def handler(req):

req.content_type = "text/plain"
req.write("Hello World!")
return apache.OK

observe that the ``import`` statement prohibits the
execution of this snippet as a script, since it causes
the import of a module that is only available from
``mod_python.so`` -- maybe someone can come up with a
good idea how to make mod_python web scripts executable
from the command line some day; developers will love
that.
4) in case the directory where the pythonXX.dll is to be
found should *not* appear on the environment variable
``path``, apache will refuse to start and issue the
following message::

Cannot load drive/dir/Apache2/modules/mod_python.so
into server: The specified module could not be
found.

this may be a problem with per-user python installations
that put the dll into the python directory, not into the
windows directory.
5) you also may want to consider setting the
``pythonhome`` environment variable -- while
experimenting, this solved my problems in one case, but
for some reason, i found myself unable to reproduce the
behavior later. anyhow, you'd simply type ::

set pythonhome=drive:\path\to\python

or create an entry in ``autoexec.bat``, or set the
variable in the system administration.
6) one user also mentioned insufficient access rights in
the scripts directory as a potential cause of
malfunction -- apache does ordinarily not run as a
common user, but under a special account that must be
granted execution access to the directories where you
deploy your web application (i did not have his problem,
but may be this is due to apache running with
administrator rights, which is not a brilliant idea to
boot).
7) enjoy.
greetings,

_wolf
Jul 18 '05 #1
1 2253
i should add that one must make sure that sufficient
rights are granted to whatever account the apache
service is run under to read and execute not only in the
web application directory, but also *in the python
directory* -- i guess this point is easily missed. as a
quick check whether this may be one of your problems
(which normally results in the message ``could not
import mod_python.apache`` in the apache errors log
file) you can =either= temporarily set the apache
service account to administrator (provided you have the
rights to do so) =or=, alternatively, go to the python
directory and grant the ``SYSTEM`` account execution
rights. of course, this does not work on fat32 volumes.
-- hope these tips in conjunction with my preceding
posting help people fly their apps,

_wolf
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ted | last post by:
Hello, I'm thinking about trying out mod_python 3.1 and was wondering if anyone could share their experiences with it. I use Jakarata Tomcat and Struts at work and I like the MVC pattern but...
6
by: Piet | last post by:
Hi there, I cannot install mod_python v3.1.3 on either Win2k/ActivePython 2.3.2 or WinMe/Python 2.3.4. When I run the Windows installer, I get the following error message: Traceback (most recent...
2
by: Dan | last post by:
I've been writing a server application in Python. The app listens on a socket and interfaces to a database. Now I'd like to write a web application to also access the database. It seems natural...
2
by: Neuruss | last post by:
I need help with this issue. All my attempts to get it up and running failed, and the documentation I found so far didn't help me at all. I'm trying to configure this components together: -...
3
by: Robert W. | last post by:
I'm embarking on a project that will have both a desktop application and a Pocket PC application. It seems logical to have as much code as possible sitting in a shared project, which would be...
1
by: treelife | last post by:
I'm getting and internal server error when | run the following mod_python script. I am actually trying to run Django. Script: from mod_python import apache def handler(req):...
2
by: Scott | last post by:
I am trying to get a mod_python application to read an existing PHP session. I need some data that was set in the session by the PHP application. I am using the mod_python Session class but even...
1
by: Jan Danielsson | last post by:
Hello all, I have written a web-based voting system (add question, add possible answers to that question, and let users vote) in python. It uses: - mod_python - postgreql (through psycopg2) ...
13
by: Ilias Lazaridis | last post by:
How to detect memory leaks of python programms, which run in an environment like this: * Suse Linux 9.3 * Apache * mod_python The problem occoured after some updates on the infrastructure....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.