1

My project is under: /home/projects/testing and I'm adding this to the buttom of my /etc/httpd/conf/httpd.conf file on Centos machine, but that is not working,

<Location "/testing/">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE testing.settings
    PythonOption django.root /testing
    PythonDebug On
    PythonPath "['/home/projects/'] + sys.path"
</Location>

but when requesting http://localhost/testing/jobs for example, I get:

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
    result = object(req)

.............

 File "/usr/lib/python2.4/site-packages/Django-1.1.1-py2.4.egg/django/conf/__init__.py", line 75, in __init__
    raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)

ImportError: Could not import settings 'testing.settings' (Is it on sys.path? Does it have syntax errors?): No module named testing.settings

2 Answers 2

3

You want both, the projects folder and the testing folder in your PythonPath, because your project uses paths without the "testing" in it:

PythonPath "['/home/projects/', '/home/projects/testing/'] + sys.path"
3
  • updated the PythonPath as instructed, and made the settings directly on settings file inside the project. Still no luck.
    – khelll
    Mar 30, 2010 at 13:01
  • @reko_t: the traceback says "import error", "no module named testing.settings". Assuming that the files /home/projects/testing/__init__.py and /home/projects/testing/settings.py exist, the /home/projects on the path should suffice. This is why I'd say it was more likely that mod_python can't read the files, rather than can't find them.
    – MattH
    Mar 30, 2010 at 13:10
  • 1
    If /home/projects/testing/__init__.py doesn't exist, then importing testing.settings will fail. I'd suggest making your python path as @reko_t suggested, but then use: SetEnv DJANGO_SETTINGS_MODULE settings. This should work weather __init__.py exists or not.
    – Jack M.
    Mar 30, 2010 at 16:47
0

The path looks okay to me, I've just double checked that items in sys.path work with trailing slashes.

I'd suggest that this is a file permissions issue:

  • Does the user apache is running under have access to the project files?
  • Is selinux preventing access?
2
  • made the folder with permission 777, I'm using Centos as well, there is no selinux AFAIK. Still no luck.
    – khelll
    Mar 30, 2010 at 13:06
  • I've not had any exposure to Centos, but the existence of this document, centos.org/docs/5/html/5.1/Deployment_Guide/… would lead me to believe that Centos doesn't intrinsically lack selinux.
    – MattH
    Mar 30, 2010 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.