Forums

Trouble Getting Started

When creating the web application, I chose python 3.4 and no virtualenv.

My wsgi file (/var/www/clown_pythonanywhere_com_wsgi.py) looks like this:

import sys

path = '/home/clown/LatticeAnimals/counting_site/counting_site/'
if path not in sys.path:
    sys.path.append(path)

from wsgi import application

Application directory structure is (showing only relevant parts):

/home/clown/LatticeAnimals/counting_site/
/home/clown/LatticeAnimals/counting_site/manage.py
/home/clown/LatticeAnimals/counting_site/counting_site/
/home/clown/LatticeAnimals/counting_site/counting_site/settings.py
/home/clown/LatticeAnimals/counting_site/counting_site/wsgi.py
/home/clown/LatticeAnimals/counting_site/counting_app/

Content of wsgi.py:

"""
WSGI config for counting_site project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "counting_site.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Full stack trace of error:

2016-03-27 18:36:05,597 :Traceback (most recent call last):
2016-03-27 18:36:05,598 :  File "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 128, in __init__
2016-03-27 18:36:05,598 :    mod = importlib.import_module(self.SETTINGS_MODULE)
2016-03-27 18:36:05,598 :  File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
2016-03-27 18:36:05,598 :    return _bootstrap._gcd_import(name[level:], package, level)
2016-03-27 18:36:05,598 :  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
2016-03-27 18:36:05,599 :  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
2016-03-27 18:36:05,599 :  File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
2016-03-27 18:36:05,599 :  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
2016-03-27 18:36:05,599 :  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
2016-03-27 18:36:05,599 :  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
2016-03-27 18:36:05,600 :  File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked
2016-03-27 18:36:05,600 :ImportError: No module named 'counting_site'
2016-03-27 18:36:05,600 :
2016-03-27 18:36:05,600 :During handling of the above exception, another exception occurred:
2016-03-27 18:36:05,600 :
2016-03-27 18:36:05,600 :Traceback (most recent call last):
2016-03-27 18:36:05,600 :  File "/bin/user_wsgi_wrapper.py", line 138, in __call__
2016-03-27 18:36:05,601 :    self.error_log_file.logger.exception("Error running WSGI application")
2016-03-27 18:36:05,601 :  File "/usr/lib/python3.4/logging/__init__.py", line 1310, in exception
2016-03-27 18:36:05,601 :    self.error(msg, *args, **kwargs)
2016-03-27 18:36:05,601 :  File "/usr/lib/python3.4/logging/__init__.py", line 1303, in error
2016-03-27 18:36:05,602 :    self._log(ERROR, msg, args, **kwargs)
2016-03-27 18:36:05,602 :  File "/usr/lib/python3.4/logging/__init__.py", line 1409, in _log
2016-03-27 18:36:05,602 :    self.handle(record)
2016-03-27 18:36:05,603 :  File "/usr/lib/python3.4/logging/__init__.py", line 1418, in handle
2016-03-27 18:36:05,603 :    if (not self.disabled) and self.filter(record):
2016-03-27 18:36:05,603 :  File "/usr/lib/python3.4/logging/__init__.py", line 706, in filter
2016-03-27 18:36:05,604 :    for f in self.filters:
2016-03-27 18:36:05,604 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2016-03-27 18:36:05,604 :    app_iterator = self.app(environ, start_response)
2016-03-27 18:36:05,604 :  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
2016-03-27 18:36:05,604 :    self.load_middleware()
2016-03-27 18:36:05,604 :  File "/usr/local/lib/python3.4/dist-packages/django/core/handlers/base.py", line 44, in load_middleware
2016-03-27 18:36:05,605 :    for middleware_path in settings.MIDDLEWARE_CLASSES:
2016-03-27 18:36:05,605 :  File "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 54, in __getattr__
2016-03-27 18:36:05,605 :    self._setup(name)
2016-03-27 18:36:05,605 :  File "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 49, in _setup
2016-03-27 18:36:05,605 :    self._wrapped = Settings(settings_module)
2016-03-27 18:36:05,605 :  File "/usr/local/lib/python3.4/dist-packages/django/conf/__init__.py", line 132, in __init__
2016-03-27 18:36:05,605 :    % (self.SETTINGS_MODULE, e)
2016-03-27 18:36:05,605 :ImportError: Could not import settings 'counting_site.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named 'counting_site'

When I try python 2.7, I get the following error:

2016-03-27 19:22:54,329 :ImportError: No module named my_wsgi_file
2016-03-27 19:22:54,849 :Traceback (most recent call last):
2016-03-27 19:22:54,849 :  File "/bin/user_wsgi_wrapper.py", line 138, in __call__
2016-03-27 19:22:54,849 :    self.error_log_file.logger.exception("Error running WSGI application")
2016-03-27 19:22:54,849 :  File "/usr/lib/python2.7/logging/__init__.py", line 1185, in exception
2016-03-27 19:22:54,850 :    self.error(msg, *args, **kwargs)
2016-03-27 19:22:54,850 :  File "/usr/lib/python2.7/logging/__init__.py", line 1178, in error
2016-03-27 19:22:54,850 :    self._log(ERROR, msg, args, **kwargs)
2016-03-27 19:22:54,850 :  File "/usr/lib/python2.7/logging/__init__.py", line 1270, in _log
2016-03-27 19:22:54,850 :    record = self.makeRecord(self.name, level, fn, lno, msg, args, exc_info, func, extra)
2016-03-27 19:22:54,851 :  File "/usr/lib/python2.7/logging/__init__.py", line 1244, in makeRecord
2016-03-27 19:22:54,851 :    rv = LogRecord(name, level, fn, lno, msg, args, exc_info, func)
2016-03-27 19:22:54,851 :  File "/usr/lib/python2.7/logging/__init__.py", line 284, in __init__
2016-03-27 19:22:54,851 :    self.threadName = threading.current_thread().name
2016-03-27 19:22:54,851 :  File "/usr/lib/python2.7/threading.py", line 1160, in currentThread
2016-03-27 19:22:54,851 :    return _active[_get_ident()]
2016-03-27 19:22:54,852 :  File "/bin/user_wsgi_wrapper.py", line 130, in __call__
2016-03-27 19:22:54,852 :    app_iterator = self.app(environ, start_response)
2016-03-27 19:22:54,852 :  File "/bin/user_wsgi_wrapper.py", line 144, in import_error_application
2016-03-27 19:22:54,852 :    raise e
2016-03-27 19:22:54,852 :ImportError: No module named my_wsgi_file

I think the problem here is that your path is set to /home/clown/LatticeAnimals/counting_site/counting_site/, and you're saying that the settings module is in counting_site.settings, which means that it will look for it in the file /home/clown/LatticeAnimals/counting_site/counting_site/counting_site/settings.py -- with three counting_sites rather than two.

If you set the system path to /home/clown/LatticeAnimals/counting_site/ and then do

from counting_site.wsgi import application

...then it should work better.

Yes! thank you.

Not being able to set up was very frustrating experience.

I tried to follow the tutorial and the example in the default wsgi file, maybe I did something wrong