Django project settings module is not being picked up from within mod_wsgi. Import fine from within python.

11 views
Skip to first unread message

unknownerror

unread,
Feb 6, 2010, 2:09:47 PM2/6/10
to modwsgi
I've added a file called sites.pth to my standard python site-packages
directory and my django module can be imported via python itself. So
my question is what may be causing mod_wsgi from within apache to not
pick up on the path modules when python itself does. I've tried
various things like adding the WSGIPythonHome directive to the main
apache config. But, then none of the standard modules are found:
cannot import modules os.

Thanks for any help in advance...
Brandon

I.E.
#python
>>import mysite.settings
>>

But, when I set environment inside my wsgi file it fails to import...

I.E.
import os
import sys
import pprint

sys.path.append('/home/www')
sys.path.append('/home/www/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'

print sys.prefix
pprint.pprint(sys.path)

import mysite
#import django.core.handlers.wsgi
#application = django.core.handlers.wsgi.WSGIHandler( )

My apache error logs are as follows:
[Sat Feb 06 18:56:43 2010] [notice] Apache/2.2.14 (Unix) mod_ssl/
2.2.14 OpenSSL/0.9.8k-fips DAV/2 SVN/1.6.6 mod_wsgi/3.1 Python/2.6
configured -- resuming normal operations
[Sat Feb 06 18:56:50 2010] [error] ['/usr/lib/python2.6/site-packages/
setuptools-0.6c11-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Pylons-0.9.7-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Tempita-0.4-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
WebTest-1.2-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
WebError-0.10.1-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
WebOb-0.9.7.1-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Mako-0.2.5-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
nose-0.11.1-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
decorator-3.1.2-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
simplejson-2.0.9-py2.6-linux-i686.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
FormEncode-1.2.2-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
PasteScript-1.7.3-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
PasteDeploy-1.3.3-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Paste-1.7.2-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Beaker-1.5.1-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
WebHelpers-1.0b3-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Routes-1.11-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Pygments-1.2.2-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
TurboGears-1.1-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
tgMochiKit-1.4.2-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
TurboJson-1.2.1-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
PEAK_Rules-0.5a1.dev_r2600-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Genshi-0.5.1-py2.6-linux-i686.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
configobj-4.7.0-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
CherryPy-2.3.0-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
prioritized_methods-0.2.1-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Extremes-1.1.1-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
AddOns-0.7-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
DecoratorTools-1.7-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
BytecodeAssembler-0.5.1-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Cheetah-2.4.1-py2.6-linux-i686.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
SymbolType-1.0-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Markdown-2.0.3-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Django-1.1.1-py2.6.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
MySQL_python-1.2.3c1-py2.6-linux-i686.egg',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python26.zip',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/plat-linux2',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/lib-tk',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/lib-old',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/lib-dynload',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-
packages',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
Numeric',
[Sat Feb 06 18:56:50 2010] [error] '/usr/lib/python2.6/site-packages/
gtk-2.0',
[Sat Feb 06 18:56:50 2010] [error] '/home/www',
[Sat Feb 06 18:56:50 2010] [error] '/home/www/mysite']
[Sat Feb 06 18:56:50 2010] [error] [client ::1] mod_wsgi (pid=5596):
Target WSGI script '/usr/local/apache2/www/mysite.wsgi' cannot be
loaded as Python module.
[Sat Feb 06 18:56:50 2010] [error] [client ::1] mod_wsgi (pid=5596):
Exception occurred processing WSGI script '/usr/local/apache2/www/
mysite.wsgi'.
[Sat Feb 06 18:56:50 2010] [error] [client ::1] Traceback (most recent
call last):
[Sat Feb 06 18:56:50 2010] [error] [client ::1] File "/usr/local/
apache2/www/mysite.wsgi", line 11, in <module>
[Sat Feb 06 18:56:50 2010] [error] [client ::1] import mysite
[Sat Feb 06 18:56:50 2010] [error] [client ::1] ImportError: No module
named mysite

Brandon Miller

unread,
Feb 6, 2010, 4:10:07 PM2/6/10
to modwsgi
Fixed it...it was a permissions issue...took a while though, good god.

Thanks!
--
Regards,
Brandon

Graham Dumpleton

unread,
Feb 7, 2010, 5:47:17 PM2/7/10
to mod...@googlegroups.com
Reference to this sort of permissions issue in documentation at:

http://code.google.com/p/modwsgi/wiki/ApplicationIssues#Access_Rights_Of_Apache_User

Graham

> --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To post to this group, send email to mod...@googlegroups.com.
> To unsubscribe from this group, send email to
> modwsgi+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/modwsgi?hl=en.
>

Reply all
Reply to author
Forward
0 new messages