LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 09-27-2007, 05:12 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
apache/mod_python problem: ImportError: No module named mod_python.apache


For reasons that I won't get into in this thread, I've built a webserver that runs out of my homedir (with php & sqlite to boot). Now, however, I need python, so I'm trying to build/install mod_python. To get the build to work, I needed to also build/install python, which I've done (all running out of my homedir). I can build & install mod_python fine now. I've edited my httpd.conf to load up the mod_python.so from my homedir.

Watching apache's logs on startup, I can see it loading up mod_python:

Code:
[Thu Sep 27 14:56:32 2007] [notice] mod_python: Creating 8 session mutexes based on 256 max processes and 0 max threads.
[Thu Sep 27 14:56:32 2007] [notice] mod_python: using mutex_directory /tmp
[Thu Sep 27 14:56:32 2007] [notice] Apache/2.2.6 (Unix) PHP/5.2.4 mod_python/3.3.1 Python/2.5.1 configured -- resuming normal operations
but when I try to load up a simple hello_world.py:
Code:
from mod_python import apache

def handler(req):
    req.content_type = 'text/plain'
    req.write("Hello World!")
    return apache.OK
I get this message showing up in the apache logs:
Code:
[Thu Sep 27 14:56:48 2007] [error] make_obcallback: could not import mod_python.apache.\n
ImportError: No module named mod_python.apache
[Thu Sep 27 14:56:48 2007] [error] make_obcallback: Python path being used "['/usr/lib/python25.zip', '/usr/lib/python2.5', '/usr/lib/python2.5/plat-linux2', '/usr/lib/python2.5/lib-tk', '/usr/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/lib/python2.5/site-packages', '/var/lib/python-support/python2.5', '/var/lib/python-support/python2.5/HTMLgen']".
[Thu Sep 27 14:56:48 2007] [error] get_interpreter: no interpreter callback found.
[Thu Sep 27 14:56:48 2007] [error] [client 10.4.1.97] python_handler: Can't get/create interpreter.
any ideas on why this is happening? Could it be that the python in my homedir is not listed in the pythong path in the above error message? If so, how do I get it in there?

FWIW, I configured mod_python like so:

./configure --prefix=$HOME/local --with-apxs=$HOME/local/bin/apxs --with-python=$HOME/local/bin/python

Any help would be much appreciated.
 
Old 09-29-2007, 06:41 AM   #2
lucastic
Member
 
Registered: Aug 2003
Location: Oz
Distribution: Gentoo - Debian
Posts: 202

Rep: Reputation: 30
Yes, I would say it is something to do with your python paths. Find the file

slocate mod_python (or mod_python.apache)

Then check that the file is in a directory referred to by "Python path being used"

Dont know if thats the problem but its certainly one option you could easily eliminate
 
Old 10-10-2007, 05:13 PM   #3
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Solved.

It was a path issue. The simple solution is to set an env var PYTHONHOME to the base of the python install (i.e. where you pointed --prefix to in the configure step).

Once that's done, in the same shell, restart apache. So, in my case, it went a little like this:


Code:
./configure --prefix=$HOME/local --with-apxs=$HOME/local/bin/apxs --with-python=$HOME/local/bin/python --with-python-src=$HOME/install/Python-2.5.1
make -j2
make test
make install
$HOME/bin/apachectl -k restart
There's probably a way of doing this inside of the apache conf (or maybe even through an htaccess override), but I don't know how to do that.

Last edited by BrianK; 10-10-2007 at 05:15 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help in setting up mod_python in apache yinglcs2 Linux - Software 0 03-10-2007 05:31 PM
Apache Mod_pyton Problem: mod_python cannot open shared object file jCash Linux - Newbie 0 11-12-2006 05:48 PM
mod_python apache configuration gaddargarson Programming 2 03-09-2005 05:14 AM
Apache and mod_python not exec python scripts fIREfox Linux - Networking 1 02-11-2003 05:54 PM
Apache with mod_python mbayeb Linux - Software 2 12-24-2002 05:24 AM


All times are GMT -5. The time now is 05:28 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration