Ask Your Question

Fresh install: "ImportError: No module named site"

asked 2013-12-04 13:35:26 -0600

nicanorl gravatar image

updated 2013-12-04 14:52:39 -0600

I'm trying to deploy Askbot to production.

I'm using Ubuntu 12.04 , Apache2 and Python 2.7

Running the Django development server, the website works fine, but it doesn't seem to work under Apache.

This is my error log:

[warn] mod_wsgi: Compiled for Python/2.7.2+. 
[warn] mod_wsgi: Runtime using Python/2.7.3.
[notice] Apache/2.2.22 (Ubuntu)
mod_wsgi/3.3 Python/2.7.3 configured
-- resuming normal operations 
ImportError: No module named site
ImportError: No module named site

I added

import sys

to django.wsgi and run python2 django.wsgi, this is the output:

/var/www/example /usr/lib/python2.7

I've checked [link removed] and I see that my install is missing all folders like "/usr/lib/python2.7/site-packages/"

running python:

 import site
 <module 'site' from '/usr/lib/python2.7/site.pyc'>

This is my apache configuration file:

 #the following two directories must be both readable and writable by apache
 WSGISocketPrefix /var/run/apache2
 # this is a manually created folder: WSGIPythonEggs /var/www/example/eggs
 #the following directory must be readable by apache WSGIPythonHome
 #NOTE: all urs below will need to be adjusted if
 #settings.FORUM_SCRIPT_ALIAS is anything other than empty string (e.g.
 = 'forum/')

 #replace with with real IP address <VirtualHost>
 ServerAdmin [email removed]
 DocumentRoot /var/www/example3
 ServerName [link removed]
 #aliases to serve static media directly
 #will probably need adjustment
 Alias /m/ /var/www/example3/static/
 Alias /upfiles/ /var/www/example3/askbot/upfiles/
 <DirectoryMatch "/var/www/example3/askbot/skins/([^/]+)/media">
    Order deny,allow
    Allow from all
 <Directory "/var/www/example3/askbot/upfiles">
    Order deny,allow
    Allow from all
 #must be a distinct name within your apache configuration
 WSGIDaemonProcess askbot2
 WSGIProcessGroup askbot2
 WSGIScriptAlias / /var/www/example3/django.wsgi
 <Directory "/var/www/example3">
    Order allow,deny
    Allow from all </Directory>
    #make all admin stuff except media go through secure connection
 <LocationMatch "/admin(?!/media)">
 RewriteEngine on
     RewriteRule /admin(.*)$ [link removed]$1> [L,R=301]
 CustomLog /var/log/apache2/access_log common
 ErrorLog /var/log/apache2/askbot/error_log
 LogLevel debug </VirtualHost>

Thanks for your help!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2013-12-05 07:51:05 -0600

nicanorl gravatar image

Commented: WSGISocketPrefix /var/run/apache2 WSGIPythonHome /usr/lib/python2.7

Now it works!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2013-12-04 13:35:26 -0600

Seen: 10,947 times

Last updated: Dec 05 '13