Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8245015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:03:13+00:00 2026-06-07T22:03:13+00:00

After working with django’s dev server for the past two months, the time finally

  • 0

After working with django’s dev server for the past two months, the time finally came to move to apache + mod_wsgi.

The problem is when I go to my site (let’s call it junux), to the URL mapped to the django app, things do not seem to work. When running the dev server on the server things work properly.

The bottom-line of the error is given to me in the apache error_log:

ImportError: Could not import settings ‘junux_site.settings’ (Is it on
sys.path?): No module named importlib

I’m aware this is similar to many other questions on the matter (there are so many that I won’t even quote them here), but I still haven’t found the answer. I have read quite a few guides on moving to production, including django’s deployment docs, mod_wsgi’s guides, some pycon presentation and have been googling the issue all day…

Lots of fun and exciting details below.

Any help will be appreciated.
Thanks in advance.


The configuration:

  • Apache 2.2.15 with mod_wsgi on CentOS 6
  • Python 2.7.3 compiled from source
  • The site uses a virtualenv

This is the error page apache returns:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Apache/2.2.15 (CentOS) Server at junux.net Port 80

The apache error_log reveals the following information:

mod_wsgi (pid=22502): Create interpreter 'junux.net|/dev'.
mod_wsgi (pid=22502): Exception occurred processing WSGI script '/var/www/junux_dev/junux_site/wsgi.py'.
Traceback (most recent call last):
  File "/var/www/junux_dev/venv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 219, in __call__
    self.load_middleware()
  File "/var/www/junux_dev/venv/lib/python2.7/site-packages/django/core/handlers/base.py", line 39, in load_middleware
    for middleware_path in settings.MIDDLEWARE_CLASSES:
  File "/var/www/junux_dev/venv/lib/python2.7/site-packages/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/var/www/junux_dev/venv/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/var/www/junux_dev/venv/lib/python2.7/site-packages/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'junux_site.settings' (Is it on sys.path?): No module named importlib

The relevant wsgi.py:

import os
import sys
import site

# use our virtual environment
SITE_DIR = os.path.dirname(__file__)
PROJECT_ROOT = os.path.dirname(SITE_DIR)
site_packages = os.path.join(PROJECT_ROOT, 'venv/lib/python2.7/site-packages')
site.addsitedir(os.path.abspath(site_packages))
sys.path.insert(0, SITE_DIR)
sys.path.insert(1, PROJECT_ROOT)

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "junux_site.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

And httpd.conf:
(more stuff here from the default apache configuration file)

<VirtualHost *:80>
        ServerName junux.net
        ServerAlias junux.net
        ServerAdmin admin@junux.net

        WSGIScriptAlias /test /var/www/test/hello.py
        WSGIScriptAlias /dev /var/www/junux_dev/junux_site/wsgi.py

        <Directory /var/www/test >
        Order allow,deny
        Allow from all
        </Directory>

        <Directory /var/www/junux_dev >
        Options FollowSymLinks
        Order allow,deny
        Allow from all
        </Directory>

</VirtualHost>

LogLevel info

There’s a WSGIScriptAlias to /test to provide a sanity-check that mod_wsgi indeed works. It does. When opening that URL the (very simple) application works (a typical hello world).

I have set permissions to chmod o+r on my wsgi file and chmod o+rx on the entire /var/www/junux_dev dir, as instructed in the pycon-sydney-2010 presentation refered to from here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:03:14+00:00Added an answer on June 7, 2026 at 10:03 pm

    What version of Python was mod_wsgi compiled against? Looks like you might have multiple Python installations on the system and your virtual environment is using Python 2.7, but your mod_wsgi is compiled against 2.6.

    Am basing this guess on fact that importlib was only added in Python 2.7, so if mod_wsgi was compiled for 2.6 and using that base installation, then would fail to find importlib.

    Run checks:

    http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Shared_Library
    http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Installation_In_Use

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using django-1.2 and python-2.6 and I am using mysql server. After working
I'm taking the plunge into iPhone development after about two years working with django.
I got my Apache Mod_WSGI and Django working following http://blog.stannard.net.au/2010/12/11/installing-django-with-apache-and-mod_wsgi-on-ubuntu-10-04/ with a twist that
After working in Eclipse for the past 3 years and memorizing all of the
I can't believe I'm back to this after working with WPF for 3 months
After working on a Django project for a while, I now have to do
After working through the Django tutorial I'm now trying to build a very simple
After a very standard and minor release, our Apache/Nginx/Django/wsgi setup ceased to function with
I started working on Django 1.0 Web Site Development and have gotten my server
I've been working a Django-CMS plugin that uses the Flickr API, and after much

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.