0

Working on a RHEL 5 server. Trying to make a small CherryPy app that takes in arguments from the url (ex. internet.com/cherrypy/data/22/45 would return 22 and 45) and then use that to query a SQL Server with those arguments incorporated. Then returns that in JSON format. Stuck at a fairly big roadblock.

RHEL 5 ships with Python 2.4, 2.4 doesn't have native JSON handling, so I installed Python26 from EPEL alongside 2.4. I can run 2.6 with the python26 command, as well as 2.4 with the plain python command. I left 2.4 on as I've read yum depends on 2.4. I then removed CherryPy from 2.4, and reinstalled it for 2.6. I'm running CherryPy under Apache2 with Mod_wsgi. So I speculate that could be the root of the problem. I thought if I added a shebang (just learned of that today, great name, hah.) to my CherryPy script that would interpret it with 2.6, but it did not and I'm still getting 500 errors when I go to the root of the CherryPy application (internet.com/cherrpy/). This is my script presently:

#!/usr/bin/python2.6

import sys
sys.stdout = sys.stderr

import atexit
import threading
import cherrypy

cherrypy.config.update({'environment': 'embedded'})

class Root(object):
    def index(self):
        return 'Nothing to see here. Move along.'
    index.exposed = True

    def data(self, building, ser):
        return 'You requested data for SER number: ' + ser + ' in building number: ' + building
    data.exposed = True

application = cherrypy.Application(Root(), script_name=None, config=None)

I have mod_wsgi 3.2 (mod_wsgi-3.2-1.el5.x86_64.rpm) installed, which I believe I downloaded via wget and installed locally because it wasn't in the RHEL repo.

This is the line in my httpd.conf that applies to CherryPy:

WSGIScriptAlias /cherrypy /fs1/html/data/scripts/test.py

I'm not sure if the cause is having two versions of python on the system and it not knowing which to interpret the script with, or mod_wsgi is the culprit and I have to reinstall a version built for 2.6 (This and the linked question suggests that). Does anyone know for certain what I should do?

Edit: This guide on the mod_wsgi google code page indicates building with an argument for a different version of python. Should I be doing that, and pass the argument "--with-python=python26"?

Edit2: Tried building mod_wsgi from souce with:

sudo ./configure --with-python=/usr/bin/python26

But upon running make I'm greeted with this junk: http://pastebin.com/khzctxDT That's as much as I could copy, tried to write the output to a file with "sudo make > file.txt" but I get a permission denied error. I miss having root...

Omega192
  • 125
  • 1
  • 1
  • 8

1 Answers1

1

Yes you need to rebuild mod_wsgi against the specific Python version you intend to use.

As described in requirements detailed in installation instructions provided with mod_wsgi source code, you must have the development packages for both Python and Apache installed. You appear not to have the development package for Python installed.

So, check the installation instructions provided with mod_wsgi itself and also those at:

http://code.google.com/p/modwsgi/wiki/QuickInstallationGuide

Graham Dumpleton
  • 6,090
  • 2
  • 21
  • 19
  • Oh I am a nitwit. I had python-devel installed, but not python26-devel. Just successfully rebuilt mod_wsgi and my cherrypy script is now running. Thanks! – Omega192 Jul 25 '11 at 14:28