I'm trying to run a Django/Python3 application with Gunicorn. Everyone agrees that this is easy, but deploying web applications seems extremely complicated to me, having been raised on Java/Tomcat apps.
So I installed Gunicorn:
$ sudo pip3 install gunicorn
I navigated to the directory with the ./manage.py
file and execute:
$ gunicorn my_project/wsgi:application
and I get a traceback, the gist of which is:
ImportError: No module named 'my_project/wsgi'
My wsgi.py
file is exactly as Django generated it, and is located at my_project/wsgi.py
:
"""
WSGI config for titlematch_api 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", "titlematch_api.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
I am using Python 3, Django 1.8, and gunicorn 19.3.0
I was able to get gunicorn to run the following test:
def app(environ, start_response):
"""Simplest possible application object"""
data = b'Hello, World!\n'
status = '200 OK'
response_headers = [
('Content-type','text/plain'),
('Content-Length', str(len(data)))
]
start_response(status, response_headers)
return iter([data])
What am I doing wrong? I've tried with and without a virtualenv.
Try:
It is meant to be a module path, not a file system path.