First time here? Check out the FAQ!

Revision history  [back]

Fresh install: "ImportError: No module named site"

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
sys.stderr.write('\n'.join(sys.path))

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

/var/www/example /usr/lib/python2.7
/usr/lib/python2.7/plat-linux2
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
 /usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages

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
 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
 /usr/lib/python2.7
 #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 127.0.0.1 with real IP address <VirtualHost 23.94.43.156:80>
 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
 </DirectoryMatch>
 <Directory "/var/www/example3/askbot/upfiles">
    Order deny,allow
    Allow from all
 </Directory>
 #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]
     </LocationMatch>
 CustomLog /var/log/apache2/access_log common
 ErrorLog /var/log/apache2/askbot/error_log
 LogLevel debug </VirtualHost>

Thanks for your help!

Fresh install: "ImportError: No module named site"

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
sys.stderr.write('\n'.join(sys.path))

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

/var/www/example /usr/lib/python2.7
/usr/lib/python2.7/plat-linux2
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
 /usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages

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
 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
 /usr/lib/python2.7
 #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 127.0.0.1 with real IP address <VirtualHost 23.94.43.156:80>
 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
 </DirectoryMatch>
 <Directory "/var/www/example3/askbot/upfiles">
    Order deny,allow
    Allow from all
 </Directory>
 #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]
     </LocationMatch>
 CustomLog /var/log/apache2/access_log common
 ErrorLog /var/log/apache2/askbot/error_log
 LogLevel debug </VirtualHost>

Thanks for your help!

Fresh install: "ImportError: No module named site"

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 for
Python/2.7.2+.  [] [warn] mod_wsgi: mod_wsgi:
Runtime using Python/2.7.3.
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
sys.stderr.write('\n'.join(sys.path))

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

/var/www/example /usr/lib/python2.7
/usr/lib/python2.7/plat-linux2
/usr/lib/python2.7/lib-tk
/usr/lib/python2.7/lib-old
/usr/lib/python2.7/lib-dynload
 /usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages

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

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
 /usr/lib/python2.7
 #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 127.0.0.1 with real IP address <VirtualHost 23.94.43.156:80>
 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
 </DirectoryMatch>
 <Directory "/var/www/example3/askbot/upfiles">
    Order deny,allow
    Allow from all
 </Directory>
 #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]
     </LocationMatch>
 CustomLog /var/log/apache2/access_log common
 ErrorLog /var/log/apache2/askbot/error_log
 LogLevel debug </VirtualHost>

Thanks for your help!