Everything is working but modpython

50 views
Skip to first unread message

jpittet

unread,
Sep 3, 2008, 7:39:27 PM9/3/08
to Django users
I have everything running except mod_python on apache.

I can import django in the Python interpreter. I can even run python
manage.py runserver but as soon as I put it in apache, it gives me
grief. This is a
Centos 5
Python 2.4
Apache 2.2
mod_python.i386 3.2.8-3.1
Django SVN at 1.0 rc_1

Here is the error message:

--------------------------------------------------------------------------------------------------
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
287, in HandlerDispatch
log=debug)

File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line
461, in import_module
f, p, d = imp.find_module(parts[i], path)

ImportError: No module named django
--------------------------------------------------------------------------------------------------

vhost.conf
--------------------------------------------------------------------------------------------------
<Location "/mysite/">
SetHandler python-program

PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE mysite.settings
PythonOption django.root /mysite

PythonDebug On

PythonPath "['/var/www/site/htdocs'] + sys.path"

</Location>
--------------------------------------------------------------------------------------------------





Any ideas what I did wrong?

Joshua Jonah

unread,
Sep 3, 2008, 10:09:44 PM9/3/08
to django...@googlegroups.com
That error looks like you cant import django. weird.

Joshua Jonah

unread,
Sep 3, 2008, 10:11:10 PM9/3/08
to django...@googlegroups.com
Likely it's an issue with the instance of python that mod_python is complied to, do you have more than one version of python?

Graham Dumpleton

unread,
Sep 4, 2008, 12:05:33 AM9/4/08
to Django users
Run command line 'python' you used to install Django and then go:

$ python
Python 2.3.5 (#1, Mar 20 2005, 20:38:20)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.__file__
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/Django-0.95.1-py2.3.egg/django/__init__.pyc'

Post your output so we can see where Django is actually installed.

Graham

jpittet

unread,
Sep 4, 2008, 11:37:13 AM9/4/08
to Django users
I went on to the IRC channel and Magus- helped me solve the problem.

Centos has permissions on the user folder I had the SVN trunk in that
was set to 700. /home/username/django-trunk is where I symlinked
django from.

To solve this problem all I had to do was set the permissions to 711
and it worked.

After that was fixed I also had to set the Python Egg Cache folder to
solve another problem in CentOS

# mkdir -p /var/cache/www/pythoneggs
# chown apache /var/cache/www/pythoneggs

Add this to the <Location> Directive
SetEnv PYTHON_EGG_CACHE "/var/cache/www/djangotemplates"


Thanks for your responses!
Reply all
Reply to author
Forward
0 new messages