Heroku - No module named wsgi
django, gunicorn, heroku
Solution
This is an old question but I'm responding to it nonetheless as I faced this exact problem recently and the answer by Intenex although helpful was not able to resolve my issue.
As pointed out by Intenex you're probably missing the `wsgi.py` file. This could be because you've created your project using Django 1.3 or a previous version. Creating a project using Django 1.4 automatically creates the `wsgi.py` just like `manage.py`, `settings.py`.
Unlike what Intenex has pointed out, here's what you should do. Assuming you're on Django 1.3 or earlier version, create `wsgi.py` file in the project directory (same directory as `manage.py` etc.) and add the following to your `wsgi.py` file:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
# This application object is used by the development server
# as well as any WSGI server configured to use this file.
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Note the difference in the last 2 statements compared to Intenex's answer.
With this you should be able to run `foreman start` with the following in your Procfile:
`web: gunicorn mysite.wsgi`
Problem
I followed the getting started Django guide on the Heroku support center but I am getting the following error when I try to start it on either Heroku or with foreman: ``` ImportError: No module named wsgi ``` Here is my procfile: ``` web: gunicorn testproject.wsgi -b 0.0.0.0:$PORT ``` Here is my django project settings file: ``` from datetime import date, timedelta import os oneyr = date.today() + timedelta(days=365) PROJECT_DIR = os.path.dirname(__file__) DEBUG = os.environ.get('DEBUG') TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), ) MANAGERS = ADMINS TIME_ZONE = 'Europe/London' LANGUAGE_CODE = 'en-gb' USE_I18N = False USE_L10N = True MEDIA_ROOT = os.path.join(PROJECT_DIR, 'static/') MEDIA_URL = '/static/' STATICFILES_DIRS = ( os.path.join(PROJECT_DIR, 'static/'), ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ) MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ) ROOT_URLCONF = 'testproject.urls' TEMPLATE_DIRS = ( os.path.join(PROJECT_DIR, 'templates') ) INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'gunicorn', 'storages', ) STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage' ``` Does anyone have any idea why this app won't start?