Solved

[Ubuntu Django] Could not import settings 'settings'

Posted on 2013-12-06
1
660 Views
Last Modified: 2013-12-06
I try to install django project on Ubuntu with Apache.

Instructions can be found in article:
http://debianworld.ru/articles/ustanovka-i-nastrojka-apache-mod_wsgi-django-mysql-v-debian-ubuntu/
Sorry for russian description, but commands are onenglish so I think this article can be useful.

I am getting an error:

Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57] mod_wsgi (pid=8114): Exception occurred processing WSGI script '/var/www/debianworld_ru/deploy/django.wsgi'.
[Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57] Traceback (most recent call last):
[Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57]   File "/usr/local/lib/python2.7/dist-packages/Django-1.4.10-py2.7.egg/django/core/handlers/wsgi.py", line 219, in __call__
[Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57]     self.load_middleware()
[Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57]   File "/usr/local/lib/python2.7/dist-packages/Django-1.4.10-py2.7.egg/django/core/handlers/base.py", line 39, in load_middleware
[Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57]     for middleware_path in settings.MIDDLEWARE_CLASSES:
[Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57]   File "/usr/local/lib/python2.7/dist-packages/Django-1.4.10-py2.7.egg/django/utils/functional.py", line 184, in inner
[Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57]     self._setup()
[Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57]   File "/usr/local/lib/python2.7/dist-packages/Django-1.4.10-py2.7.egg/django/conf/__init__.py", line 42, in _setup
[Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57]     self._wrapped = Settings(settings_module)
[Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57]   File "/usr/local/lib/python2.7/dist-packages/Django-1.4.10-py2.7.egg/django/conf/__init__.py", line 95, in __init__
[Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57]     raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Fri Dec 06 07:00:51 2013] [error] [client 10.100.10.57] ImportError: Could not import settings 'settings' (Is it on sys.path?): No module named settings

Open in new window


VirtualHost configuration:

<VirtualHost *:80>
    ServerName ibm.com
    ServerAlias www.ibm.com
   
    ErrorLog    /var/www/debianworld_ru/logs/error_log
    CustomLog   /var/www/debianworld_ru/logs/access_log common

    WSGIScriptAlias / /var/www/debianworld_ru/deploy/django.wsgi

    WSGIDaemonProcess dw-site user=dw group=dw home=/var/www/debianworld_ru/media/ \
                      processes=2 threads=4 maximum-requests=100 display-name=apache-dw-wsgi
    WSGIProcessGroup dw-site

    Alias "/media_admin/" "/usr/lib/python2.7/dist-packages/django/contrib/admin/static/"
    <Location "/media_admin/">
        SetHandler None
    </Location>

    Alias "/media/" "/var/www/debianworld_ru/media/"
    <Location "/media/">
        SetHandler None
    </Location>
</VirtualHost>

Open in new window


Please let me know if you need any additional information to help me.
Thank you.
0
Comment
Question by:ChantingWolf
1 Comment
 

Accepted Solution

by:
ChantingWolf earned 0 total points
ID: 39700813
A fix:

Aded path to settings file in file deploy/django.wsgi
sys.path.append( "/var/www/debianworld_ru/apps/apps" )

#/usr/bin/python
import os, sys

dn = os.path.dirname
PROJECT_ROOT = os.path.abspath( dn(dn(__file__)) )
DJANGO_PROJECT_ROOT = os.path.join(PROJECT_ROOT, 'apps')

sys.path.append( DJANGO_PROJECT_ROOT )
sys.path.append( "/var/www/debianworld_ru/apps/apps" )

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

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

Open in new window

0

Featured Post

Don't miss ATEN at NAB Show April 24-27!

Visit ATEN at NAB Show to learn how our "Seamlessly Entertaining" solutions deliver fast, precise video streaming without delays for the broadcasting and media environment. ATEN will showcase its 16x16 Modular Matrix Switch (VM1600) and KVM Over IP Solution (KE6900 series).

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Strings in Python are the set of characters that, once defined, cannot be changed by any other method like replace. Even if we use the replace method it still does not modify the original string that we use, but just copies the string and then modif…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question