ImportError No module named site

2,183 views
Skip to first unread message

Ross Epstein

unread,
Jan 31, 2014, 8:23:22 PM1/31/14
to mod...@googlegroups.com
I've been trying for a while to get this sorted out and still no luck. Upon restart, apache logs ImportError: No module named site.

My machine has two python installations, 2.6 and 2.7. I was having issues previously with mod_wsgi being compiled for 2.6, so I recompiled for 2.7 and it looks like it's compiled correctly: [Sat Feb 01 01:13:39 2014] [notice] Apache/2.2.26 (Unix) DAV/2 mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations

Here's my httpd.conf

WSGISocketPrefix /var/run/apache2
WSGIPythonHome /usr/lib64/python2.7/
WSGIPythonPath /home/ec2-user/[redacted]:/usr/lib64/python2.7/site-packages:/usr/lib64/python2.7

<VirtualHost *:80>
        DocumentRoot /home/ec2-user/[redacted]
        ServerName 54.203.106.173
        ErrorLog /home/ec2-user/[redacted]/logs/apache_error.log
        CustomLog /home/ec2-user/[redacted]/logs/apache_access.log combined
        WSGIScriptAlias / /home/ec2-user/[redacted]/apache/django.wsgi
        Alias /static/ /home/ec2-user/[redacted]/static/

        <Directory /home/ec2-user/[redacted]/media>
                Order deny,allow
                Allow from all
        </Directory>

        <Directory /home/ec2-user/[redacted]/apache>
                Order deny,allow
                Allow from all
        </Directory>

        LogLevel warn
</VirtualHost>

and django.wsgi:
--------------------------
import os,sys
sys.path.append('/home/ec2-user/[redacted]')
#sys.path.append('/usr/lib/python2.7')

apache_configuration = os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)
sys.path.append('/Volumes/Mac OS X/Projects')
sys.path.append('/Volumes/Mac OS X/')

os.environ['DJANGO_SETTINGS_MODULE'] = '[redacted].settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
--------------------------------

Looks like my library isn't being referenced correctly, but I've included that in the PythonPath. Any help is much appreciated. Thanks.

Graham Dumpleton

unread,
Feb 1, 2014, 5:18:34 AM2/1/14
to mod...@googlegroups.com
On 01/02/2014, at 12:23 PM, Ross Epstein <ro...@cordatasales.com> wrote:

I've been trying for a while to get this sorted out and still no luck. Upon restart, apache logs ImportError: No module named site.

My machine has two python installations, 2.6 and 2.7. I was having issues previously with mod_wsgi being compiled for 2.6, so I recompiled for 2.7 and it looks like it's compiled correctly: [Sat Feb 01 01:13:39 2014] [notice] Apache/2.2.26 (Unix) DAV/2 mod_wsgi/3.4 Python/2.7.5 configured -- resuming normal operations

Here's my httpd.conf

WSGISocketPrefix /var/run/apache2
WSGIPythonHome /usr/lib64/python2.7/

If your Python 2.7 is installed under /usr (ie., that is what sys.prefix in interpreter returns), you do not need to set WSGIPythonHome.

WSGIPythonPath /home/ec2-user/[redacted]:/usr/lib64/python2.7/site-packages:/usr/lib64/python2.7

You similarly should not need to be adding:

/usr/lib64/python2.7/site-packages:/usr/lib64/python2.7

to WSGIPythonPath.

So take both out for a start.

To confirm things though, work out what sys.prefix is on the command line interpreter for your Python installation that you want to use:


Also work out what your mod_wsgi.so is actually compiled against:


Post the details from this.

Graham

--
You received this message because you are subscribed to the Google Groups "modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to modwsgi+u...@googlegroups.com.
To post to this group, send email to mod...@googlegroups.com.
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages