Forums

Mezzanine4 config wsgi file

Hi, Yesterday I installed Mezzanine-4.0.0 and I have a silly issue when I config the wsgi file in the tab "web" tha application isn't working, this is the message: ImportError: No module named 'FEBA2.settings'

I think due to the new mezzanine creates a folder inside the main folder of the project and creates an application (django style), but I don't know how config wsgi to define this new folder.

this is wsgi working with mezzanine-3.10.1 and isn't with mezzanine-4 I have tested some variances and all failed.

import os
import sys

# add project folder and its parent folder to path. mezzanine needs both.
for path in ['/home/mateuo/', '/home/mateuo/FEBA']:
    if path not in sys.path:
        sys.path.append(path)

# specify django settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'FEBA.settings'

# load default django wsgi app
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Thank you in advance

[edited by admin: formatting]

do you have two projects, one called FEBA and one called FEBA2?

Hi Conrad,

Thank you for your reply. Yes I have two projects one called FEBA and the other FEBA2.

oh I took a look at your wsgi files. Double check the difference between your FEBA wsgi and your FEBA2 wsgi. Your FEBA2 one has a different path.

Thank you Conrad for your reply, this is checked and I proved this differences with the path and still not working

first try: for path in ['/home/mateuo/', '/home/mateuo/FEBA2']:
second try: for path in ['/home/mateuo/FEBA2/','/home/mateuo/FEBA2/FEBA2']:
'this is the FEBA2 wsgi file'
import os
import sys

# add project folder and its parent folder to path. mezzanine needs both.
for path in ['/home/mateuo/', '/home/mateuo/FEBA2']:
    if path not in sys.path:
        sys.path.append(path)

# specify django settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'FEBA2.settings'

# load default django wsgi app
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

That's really strange. Are you able to import your settings file straight into Python?

Yes indeed, Glenn. I begin to be a bit worried... I have made some tests and I have deleted some times the application and I have change the name. These are the actual names:

the mezzanine project is called ebonnin the tree is /home/mateuo/ebonnin and the settings are in /home/mateuo/ebonnin/ebonnin/settings.py

I can import the settings directly in a console with a shell "python manage.py shell" in the folder of the mezzanine project. this is the result:

(feba3_virtualenv)15:19 ~ $ cd ebonnin/
(feba3_virtualenv)15:20 ~/ebonnin $ python manage.py shell
/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/mezzanine/utils/conf.py:51: UserWarning: You haven't defined the ALLOWE
D_HOSTS settings, which Django requires. Will fall back to the domains configured as sites.
  warn("You haven't defined the ALLOWED_HOSTS settings, which "
/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/importlib/_bootstrap.py:321: RemovedInDjango19Warning: django.contrib.contenttypes.ge
neric is deprecated and will be removed in Django 1.9. Its contents have been moved to the fields, forms, and admin submodules of django.contr
ib.contenttypes.
  return f(*args, **kwds)
Python 3.4.0 (default, Jun 19 2015, 14:20:21) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from ebonnin import settings
>>> print (settings)
<module 'ebonnin.settings' from '/home/mateuo/ebonnin/ebonnin/settings.py'>
>>>

This is the log of de web application:

2015-07-15 15:09:31,711 :Traceback (most recent call last):
2015-07-15 15:09:31,711 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2015-07-15 15:09:31,712 :    self.error_log_file.logger.exception("Error running WSGI application")
2015-07-15 15:09:31,712 :  File "/usr/lib/python3.4/logging/__init__.py", line 1296, in exception
2015-07-15 15:09:31,713 :    self.error(msg, *args, **kwargs)
2015-07-15 15:09:31,713 :  File "/usr/lib/python3.4/logging/__init__.py", line 1289, in error
2015-07-15 15:09:31,713 :    self._log(ERROR, msg, args, **kwargs)
2015-07-15 15:09:31,713 :  File "/usr/lib/python3.4/logging/__init__.py", line 1395, in _log
2015-07-15 15:09:31,728 :    self.handle(record)
2015-07-15 15:09:31,728 :  File "/usr/lib/python3.4/logging/__init__.py", line 1404, in handle
2015-07-15 15:09:31,729 :    if (not self.disabled) and self.filter(record):
2015-07-15 15:09:31,729 :  File "/usr/lib/python3.4/logging/__init__.py", line 692, in filter
2015-07-15 15:09:31,730 :    for f in self.filters:
2015-07-15 15:09:31,730 :  File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2015-07-15 15:09:31,730 :    app_iterator = self.app(environ, start_response)
2015-07-15 15:09:31,730 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
2015-07-15 15:09:31,731 :    self.load_middleware()
2015-07-15 15:09:31,731 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/core/handlers/base.py", line 49, in load_middleware
2015-07-15 15:09:31,732 :    for middleware_path in settings.MIDDLEWARE_CLASSES:
2015-07-15 15:09:31,732 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 48, in __getattr__
2015-07-15 15:09:31,734 :    self._setup(name)
2015-07-15 15:09:31,734 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 44, in _setup
2015-07-15 15:09:31,735 :    self._wrapped = Settings(settings_module)
2015-07-15 15:09:31,735 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 92, in __init__
2015-07-15 15:09:31,735 :    mod = importlib.import_module(self.SETTINGS_MODULE)
2015-07-15 15:09:31,735 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/importlib/__init__.py", line 109, in import_module
2015-07-15 15:09:31,736 :    return _bootstrap._gcd_import(name[level:], package, level)
2015-07-15 15:09:31,736 :  File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
2015-07-15 15:09:31,737 :  File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
2015-07-15 15:09:31,738 :  File "<frozen importlib._bootstrap>", line 2201, in _find_and_load_unlocked
2015-07-15 15:09:31,738 :ImportError: No module named 'ebonnin.settings'
2015-07-15 15:09:38,246 :Traceback (most recent call last):
2015-07-15 15:09:38,247 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2015-07-15 15:09:38,248 :    self.error_log_file.logger.exception("Error running WSGI application")
2015-07-15 15:09:38,248 :  File "/usr/lib/python3.4/logging/__init__.py", line 1296, in exception
2015-07-15 15:09:38,248 :    self.error(msg, *args, **kwargs)
2015-07-15 15:09:38,248 :  File "/usr/lib/python3.4/logging/__init__.py", line 1289, in error
2015-07-15 15:09:38,249 :    self._log(ERROR, msg, args, **kwargs)
2015-07-15 15:09:38,249 :  File "/usr/lib/python3.4/logging/__init__.py", line 1395, in _log
2015-07-15 15:09:38,250 :    self.handle(record)
2015-07-15 15:09:38,250 :  File "/usr/lib/python3.4/logging/__init__.py", line 1404, in handle
2015-07-15 15:09:38,250 :    if (not self.disabled) and self.filter(record):
2015-07-15 15:09:38,250 :  File "/usr/lib/python3.4/logging/__init__.py", line 692, in filter
2015-07-15 15:09:38,251 :    for f in self.filters:
2015-07-15 15:09:38,251 :  File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2015-07-15 15:09:38,251 :    app_iterator = self.app(environ, start_response)
2015-07-15 15:09:38,251 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
2015-07-15 15:09:38,252 :    self.load_middleware()
2015-07-15 15:09:38,252 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/core/handlers/base.py", line 49, in load_middleware
2015-07-15 15:09:38,253 :    for middleware_path in settings.MIDDLEWARE_CLASSES:
2015-07-15 15:09:38,253 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 48, in __getattr__
2015-07-15 15:09:38,254 :    self._setup(name)
2015-07-15 15:09:38,254 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 44, in _setup
2015-07-15 15:09:38,254 :    self._wrapped = Settings(settings_module)
2015-07-15 15:09:38,255 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 92, in __init__
2015-07-15 15:09:38,255 :    mod = importlib.import_module(self.SETTINGS_MODULE)
2015-07-15 15:09:38,255 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/importlib/__init__.py", line 109, in import_module
2015-07-15 15:09:38,256 :    return _bootstrap._gcd_import(name[level:], package, level)
2015-07-15 15:09:38,256 :  File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
2015-07-15 15:09:38,257 :  File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
2015-07-15 15:09:38,257 :  File "<frozen importlib._bootstrap>", line 2201, in _find_and_load_unlocked
2015-07-15 15:09:38,257 :ImportError: No module named 'ebonnin.settings'
2015-07-15 15:09:38,788 :Traceback (most recent call last):
2015-07-15 15:09:38,788 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2015-07-15 15:09:38,789 :    self.error_log_file.logger.exception("Error running WSGI application")
2015-07-15 15:09:38,789 :  File "/usr/lib/python3.4/logging/__init__.py", line 1296, in exception
2015-07-15 15:09:38,789 :    self.error(msg, *args, **kwargs)
2015-07-15 15:09:38,789 :  File "/usr/lib/python3.4/logging/__init__.py", line 1289, in error
2015-07-15 15:09:38,790 :    self._log(ERROR, msg, args, **kwargs)
2015-07-15 15:09:38,790 :  File "/usr/lib/python3.4/logging/__init__.py", line 1395, in _log
2015-07-15 15:09:38,791 :    self.handle(record)
2015-07-15 15:09:38,791 :  File "/usr/lib/python3.4/logging/__init__.py", line 1404, in handle
2015-07-15 15:09:38,791 :    if (not self.disabled) and self.filter(record):
2015-07-15 15:09:38,791 :  File "/usr/lib/python3.4/logging/__init__.py", line 692, in filter
2015-07-15 15:09:38,792 :    for f in self.filters:
2015-07-15 15:09:38,792 :  File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2015-07-15 15:09:38,792 :    app_iterator = self.app(environ, start_response)
2015-07-15 15:09:38,792 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
2015-07-15 15:09:38,793 :    self.load_middleware()
2015-07-15 15:09:38,793 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/core/handlers/base.py", line 49, in load_middleware
2015-07-15 15:09:38,793 :    for middleware_path in settings.MIDDLEWARE_CLASSES:
2015-07-15 15:09:38,794 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 48, in __getattr__
2015-07-15 15:09:38,795 :    self._setup(name)
2015-07-15 15:09:38,795 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 44, in _setup
2015-07-15 15:09:38,795 :    self._wrapped = Settings(settings_module)
2015-07-15 15:09:38,795 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 92, in __init__
2015-07-15 15:09:38,796 :    mod = importlib.import_module(self.SETTINGS_MODULE)
2015-07-15 15:09:38,796 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/importlib/__init__.py", line 109, in import_module
2015-07-15 15:09:38,796 :    return _bootstrap._gcd_import(name[level:], package, level)
2015-07-15 15:09:38,796 :  File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
2015-07-15 15:09:38,797 :  File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
2015-07-15 15:09:38,797 :  File "<frozen importlib._bootstrap>", line 2201, in _find_and_load_unlocked
2015-07-15 15:09:38,797 :ImportError: No module named 'ebonnin.settings'
2015-07-15 15:09:38,979 :Traceback (most recent call last):
2015-07-15 15:09:38,979 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2015-07-15 15:09:38,979 :    self.error_log_file.logger.exception("Error running WSGI application")
2015-07-15 15:09:38,979 :  File "/usr/lib/python3.4/logging/__init__.py", line 1296, in exception
2015-07-15 15:09:38,980 :    self.error(msg, *args, **kwargs)
2015-07-15 15:09:38,980 :  File "/usr/lib/python3.4/logging/__init__.py", line 1289, in error
2015-07-15 15:09:38,980 :    self._log(ERROR, msg, args, **kwargs)
2015-07-15 15:09:38,981 :  File "/usr/lib/python3.4/logging/__init__.py", line 1395, in _log
2015-07-15 15:09:38,981 :    self.handle(record)
2015-07-15 15:09:38,981 :  File "/usr/lib/python3.4/logging/__init__.py", line 1404, in handle
2015-07-15 15:09:38,982 :    if (not self.disabled) and self.filter(record):
2015-07-15 15:09:38,982 :  File "/usr/lib/python3.4/logging/__init__.py", line 692, in filter
2015-07-15 15:09:38,982 :    for f in self.filters:
2015-07-15 15:09:38,982 :  File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2015-07-15 15:09:38,983 :    app_iterator = self.app(environ, start_response)
2015-07-15 15:09:38,983 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
2015-07-15 15:09:38,984 :    self.load_middleware()
2015-07-15 15:09:38,984 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/core/handlers/base.py", line 49, in load_middleware
2015-07-15 15:09:38,984 :    for middleware_path in settings.MIDDLEWARE_CLASSES:
2015-07-15 15:09:38,984 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 48, in __getattr__
2015-07-15 15:09:38,986 :    self._setup(name)
2015-07-15 15:09:38,986 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 44, in _setup
2015-07-15 15:09:38,987 :    self._wrapped = Settings(settings_module)
2015-07-15 15:09:38,987 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/conf/__init__.py", line 92, in __init__
2015-07-15 15:09:38,987 :    mod = importlib.import_module(self.SETTINGS_MODULE)
2015-07-15 15:09:38,988 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/importlib/__init__.py", line 109, in import_module
2015-07-15 15:09:38,988 :    return _bootstrap._gcd_import(name[level:], package, level)
2015-07-15 15:09:38,988 :  File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
2015-07-15 15:09:38,988 :  File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
2015-07-15 15:09:38,988 :  File "<frozen importlib._bootstrap>", line 2201, in _find_and_load_unlocked
2015-07-15 15:09:38,989 :ImportError: No module named 'ebonnin.settings'

this is my wsgi config /var/www/ebonnin_gestionatuprevencion_com_wsgi.py

import os
import sys

# add project folder and its parent folder to path. mezzanine needs both.
for path in ['/home/mateuo/', '/home/mateuo/ebonnin']:
    if path not in sys.path:
        sys.path.append(path)

# specify django settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'ebonnin.settings'

# load default django wsgi app
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

this is my pip freeze of my virtualenv (/home/mateuo/.virtualenvs/feba3_virtualenv):

(feba3_virtualenv)15:00 ~/ebonnin $ pip freeze
-f /usr/share/pip-wheels
beautifulsoup4==4.4.0
bleach==1.4.1
chardet==2.3.0
Django==1.8.3
django-contrib-comments==1.6.1
filebrowser-safe==0.4.0
future==0.14.3
grappelli-safe==0.4.0
html5lib==0.999999
Mezzanine==4.0.0
oauthlib==0.7.2
Pillow==2.9.0
pytz==2015.4
requests==2.7.0
requests-oauthlib==0.5.0
six==1.9.0
tzlocal==1.2
wheel==0.24.0

Ah! I think I've got it. The problem is that you have /home/mateuo/ on the path and that has a module in it (/home/mateuo/ebonnin) and THAT has no settings.py so Python thinks it can't find settings because there isn't one in the first ebonnin module that it finds.

Oh! right I think that's it as well , but how can I adapt the wsgy.py? I've tried some possibilities but don't work, can you help me, or give me some idea?

Thank you in advance

Work out why mezzanine needs your home directory on the path. That seems like something strange is going on. Then remove your home directory from the path.

Thank you Glenn, only remove the home directory will be enought? I will test it and I will post it.

Thank you

Hi Glenn,

Removing the home directory isn't working.

I'm running out of ideas...

Thank you for your help

Hmm. Your web app runs with the current working directory set to your home directory, and it's possible that "." is on the Python path. Try adding this to the path setup in your WSGI file:

while "." in sys.path:
    sys.path.remove(".")

(The while loop is just in case "." is on the path multiple times.)

If that doesn't work, try adding a print "Python path is", sys.path to your WSGI file somewhere near the top, then take a look at the server log and see what it prints there -- if you post it here, it might give us some clues...

Hi Giles, This is the wsgi script with the prints and your modification:

import os
import sys
print ("Python path is at top", sys.path)
# add project folder and its parent folder to path. mezzanine needs both.
for path in ['/home/mateuo/','/home/mateuo/ebonnin/']:
    if path not in sys.path:
        sys.path.append(path)
while "." in sys.path:
    sys.path.remove(".")

# specify django settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'ebonnin.settings'
print ("Python path is at the end", sys.path)
# load default django wsgi app
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Thank you for your reply, this isn't working . This is the python path at the beginning and at the end of the wsgy script:

Python path is at top ['/var/www', '.', '', '/var/www', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/plat-x86_64-linux-gnu', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/lib-dynload', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages']

Python path is at the end ['/var/www', '', '/var/www', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/plat-x86_64-linux-gnu', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/lib-dynload', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages', '/home/mateuo/', '/home/mateuo/ebonnin/']

Have you see any clue? Thanks in advance

I think the problem is that now you're adding the home directory again. If you want this to work, it's essential that neither "/home/mateuo/" nor "." is on the path.

Sorry, I have test it again without home directory and It doesn't work :( this is the wsgi file:

import os
import sys
print ("Python path is at top", sys.path)
# add project folder and its parent folder to path. mezzanine needs both.
for path in ['/home/mateuo/ebonnin/']:
    if path not in sys.path:
        sys.path.append(path)
while "." in sys.path:
    sys.path.remove(".")

# specify django settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'ebonnin.settings'
print ("Python path is at the end", sys.path)
# load default django wsgi app
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

and this is the server.log

2015-07-16 15:13:44 Python path is at top ['/var/www', '.', '', '/var/www', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/plat-x86_64-linux-gnu', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/lib-dynload', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages']
2015-07-16 15:13:44 Python path is at the end ['/var/www', '', '/var/www', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/plat-x86_64-linux-gnu', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/lib-dynload', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages', '/home/mateuo/ebonnin/']

Thank you for all your help I hope you can figure it out.

This is very strange! The empty string in the path looks odd. Let's trying code like this to remove it, just after the code that removes ".":

while "" in sys.path:
    sys.path.remove("")

Not working :( , but a new error :) django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet. at the end the error.log

this is how looks the wsgi:

import os
import sys
print ("Python path is at top", sys.path)
# add project folder and its parent folder to path. mezzanine needs both.
for path in ['/home/mateuo/ebonnin/']:
    if path not in sys.path:
        sys.path.append(path)
while "." in sys.path:
    sys.path.remove(".")
while "" in sys.path:
    sys.path.remove("")

# specify django settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'ebonnin.settings'
print ("Python path is at the end", sys.path)
# load default django wsgi app
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

this is the server.log:

    2015-07-16 17:58:20 *** Operational MODE: preforking ***
    2015-07-16 17:58:20 Python path is at top ['/var/www', '.', '', '/var/www', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/plat-x86_64-linux-gnu', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/lib-dynload', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages']
    2015-07-16 17:58:20 Python path is at the end ['/var/www', '/var/www', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/plat-x86_64-linux-gnu', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/lib-dynload', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages', '/home/mateuo/ebonnin/']
    2015-07-16 17:58:20 WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0x1cfdfb0 pid: 11390 (default app)
    2015-07-16 17:58:20 *** uWSGI is running in multiple interpreter mode ***
New error:
2015-07-16 17:58:21,274 :/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/mezzanine/utils/conf.py:51: UserWarning: You haven't defined the ALLOWED_HOSTS settings, which Django requires. Will fall back to the domains configured as sites.
2015-07-16 17:58:21,274 :  warn("You haven't defined the ALLOWED_HOSTS settings, which "
2015-07-16 17:58:22,312 :Traceback (most recent call last):
2015-07-16 17:58:22,312 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2015-07-16 17:58:22,312 :    self.error_log_file.logger.exception("Error running WSGI application")
2015-07-16 17:58:22,312 :  File "/usr/lib/python3.4/logging/__init__.py", line 1296, in exception
2015-07-16 17:58:22,313 :    self.error(msg, *args, **kwargs)
2015-07-16 17:58:22,313 :  File "/usr/lib/python3.4/logging/__init__.py", line 1289, in error
2015-07-16 17:58:22,313 :    self._log(ERROR, msg, args, **kwargs)
2015-07-16 17:58:22,313 :  File "/usr/lib/python3.4/logging/__init__.py", line 1395, in _log
2015-07-16 17:58:22,314 :    self.handle(record)
2015-07-16 17:58:22,314 :  File "/usr/lib/python3.4/logging/__init__.py", line 1404, in handle
2015-07-16 17:58:22,314 :    if (not self.disabled) and self.filter(record):
2015-07-16 17:58:22,314 :  File "/usr/lib/python3.4/logging/__init__.py", line 692, in filter
2015-07-16 17:58:22,315 :    for f in self.filters:
2015-07-16 17:58:22,315 :  File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2015-07-16 17:58:22,315 :    app_iterator = self.app(environ, start_response)
2015-07-16 17:58:22,315 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
2015-07-16 17:58:22,316 :    self.load_middleware()
2015-07-16 17:58:22,316 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/core/handlers/base.py", line 50, in load_middleware
2015-07-16 17:58:22,317 :    mw_class = import_string(middleware_path)
2015-07-16 17:58:22,317 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/utils/module_loading.py", line 26, in import_string
2015-07-16 17:58:22,319 :    module = import_module(module_path)
2015-07-16 17:58:22,319 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/importlib/__init__.py", line 109, in import_module
2015-07-16 17:58:22,319 :    return _bootstrap._gcd_import(name[level:], package, level)
2015-07-16 17:58:22,319 :  File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
2015-07-16 17:58:22,321 :  File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
2015-07-16 17:58:22,321 :  File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
2015-07-16 17:58:22,321 :  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
2015-07-16 17:58:22,321 :  File "<frozen importlib._bootstrap>", line 1129, in _exec
2015-07-16 17:58:22,322 :  File "<frozen importlib._bootstrap>", line 1448, in exec_module
2015-07-16 17:58:22,322 :  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
2015-07-16 17:58:22,322 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/mezzanine/core/middleware.py", line 20, in <module>
2015-07-16 17:58:22,324 :    from mezzanine.core.management.commands.createdb import (DEFAULT_USERNAME,
2015-07-16 17:58:22,325 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/mezzanine/core/management/commands/createdb.py", line 16, in <module>
2015-07-16 17:58:22,327 :    from mezzanine.utils.tests import copy_test_to_media
2015-07-16 17:58:22,327 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/mezzanine/utils/tests.py", line 18, in <module>
2015-07-16 17:58:22,329 :    User = get_user_model()
2015-07-16 17:58:22,329 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/contrib/auth/__init__.py", line 150, in get_user_model
2015-07-16 17:58:22,331 :    return django_apps.get_model(settings.AUTH_USER_MODEL)
2015-07-16 17:58:22,331 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/apps/registry.py", line 199, in get_model
2015-07-16 17:58:22,333 :    self.check_models_ready()
2015-07-16 17:58:22,333 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/apps/registry.py", line 131, in check_models_ready
2015-07-16 17:58:22,334 :    raise AppRegistryNotReady("Models aren't loaded yet.")
2015-07-16 17:58:22,334 :django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
2015-07-16 17:58:27,422 :/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/mezzanine/utils/conf.py:51: UserWarning: You haven't defined the ALLOWED_HOSTS settings, which Django requires. Will fall back to the domains configured as sites.
2015-07-16 17:58:27,423 :  warn("You haven't defined the ALLOWED_HOSTS settings, which "
2015-07-16 17:58:27,866 :Traceback (most recent call last):
2015-07-16 17:58:27,866 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2015-07-16 17:58:27,866 :    self.error_log_file.logger.exception("Error running WSGI application")
2015-07-16 17:58:27,866 :  File "/usr/lib/python3.4/logging/__init__.py", line 1296, in exception
2015-07-16 17:58:27,867 :    self.error(msg, *args, **kwargs)
2015-07-16 17:58:27,867 :  File "/usr/lib/python3.4/logging/__init__.py", line 1289, in error
2015-07-16 17:58:27,868 :    self._log(ERROR, msg, args, **kwargs)
2015-07-16 17:58:27,868 :  File "/usr/lib/python3.4/logging/__init__.py", line 1395, in _log
2015-07-16 17:58:27,868 :    self.handle(record)
2015-07-16 17:58:27,868 :  File "/usr/lib/python3.4/logging/__init__.py", line 1404, in handle
2015-07-16 17:58:27,869 :    if (not self.disabled) and self.filter(record):
2015-07-16 17:58:27,869 :  File "/usr/lib/python3.4/logging/__init__.py", line 692, in filter
2015-07-16 17:58:27,870 :    for f in self.filters:
2015-07-16 17:58:27,870 :  File "/bin/user_wsgi_wrapper.py", line 122, in __call__
2015-07-16 17:58:27,870 :    app_iterator = self.app(environ, start_response)
2015-07-16 17:58:27,870 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/core/handlers/wsgi.py", line 170, in __call__
2015-07-16 17:58:27,871 :    self.load_middleware()
2015-07-16 17:58:27,871 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/core/handlers/base.py", line 50, in load_middleware
2015-07-16 17:58:27,871 :    mw_class = import_string(middleware_path)
2015-07-16 17:58:27,871 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/utils/module_loading.py", line 26, in import_string
2015-07-16 17:58:27,872 :    module = import_module(module_path)
2015-07-16 17:58:27,872 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/importlib/__init__.py", line 109, in import_module
2015-07-16 17:58:27,872 :    return _bootstrap._gcd_import(name[level:], package, level)
2015-07-16 17:58:27,872 :  File "<frozen importlib._bootstrap>", line 2231, in _gcd_import
2015-07-16 17:58:27,873 :  File "<frozen importlib._bootstrap>", line 2214, in _find_and_load
2015-07-16 17:58:27,873 :  File "<frozen importlib._bootstrap>", line 2203, in _find_and_load_unlocked
2015-07-16 17:58:27,873 :  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
2015-07-16 17:58:27,873 :  File "<frozen importlib._bootstrap>", line 1129, in _exec
2015-07-16 17:58:27,874 :  File "<frozen importlib._bootstrap>", line 1448, in exec_module
2015-07-16 17:58:27,874 :  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
2015-07-16 17:58:27,874 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/mezzanine/core/middleware.py", line 20, in <module>
2015-07-16 17:58:27,875 :    from mezzanine.core.management.commands.createdb import (DEFAULT_USERNAME,
2015-07-16 17:58:27,875 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/mezzanine/core/management/commands/createdb.py", line 16, in <module>
2015-07-16 17:58:27,875 :    from mezzanine.utils.tests import copy_test_to_media
2015-07-16 17:58:27,875 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/mezzanine/utils/tests.py", line 18, in <module>
2015-07-16 17:58:27,876 :    User = get_user_model()
2015-07-16 17:58:27,876 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/contrib/auth/__init__.py", line 150, in get_user_model
2015-07-16 17:58:27,877 :    return django_apps.get_model(settings.AUTH_USER_MODEL)
2015-07-16 17:58:27,877 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/apps/registry.py", line 199, in get_model
2015-07-16 17:58:27,877 :    self.check_models_ready()
2015-07-16 17:58:27,877 :  File "/home/mateuo/.virtualenvs/feba3_virtualenv/lib/python3.4/site-packages/django/apps/registry.py", line 131, in check_models_ready
2015-07-16 17:58:27,878 :    raise AppRegistryNotReady("Models aren't loaded yet.")
2015-07-16 17:58:27,878 :django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

Well, that's some kind of progress at least :-)

That error often means that there's a mismatch between the code you're using in the WSGI file to load Django and the version of Django you're using. If you're using Django >= 1.6, then you need to use this code to load it:

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

...and not the old-style code:

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

Oh! Man, you are right at last is working.

Thank you guys, this is the class of support everyone needs.

Thank you a lot

Awesome, glad we could get it to work! And no problem at all :-)

Just wanna say thanks. This fixed my problem. Weird, undocumented from Mezzanine to have the main project folder as an app. Removing "." and "" from the path did the trick.

Excellent, glad we could help :-)

Same here, totally baffled by this error when I switched to Mezzanine 4, this post solved it for me. Thanks!

FYI the "How to Use Mezzanine on PythonAnywhere" help article should be updated to reflect this. I just followed it and ran into this same problem. Glad I found this thread ;-)

https://help.pythonanywhere.com/pages/HowtouseMezzanineonPythonAnywhere/

Good point. I have added it to the help page!