I'm following the getting started with Python tutorial at Heroku, and I'm stuck at the "Run the app locally" step. I'm on a Windows 7 machine, and I've managed all previous steps successfully. The following code was run in the Git Bash provided by the toolbelt inside a virtualenv as described. The error appears below.
The ProcFile says (as per the instructions)
web: python manage.py runserver 0.0.0.0:$PORT
and the command foreman start web fails with the error depicted below.
If I just enter python manage.py runserver 0.0.0.0:5000 into the prompt, the server starts right up and I can visit the app. Maybe this is sufficient to develop locally, but maybe not, so if anyone can shed some light on what's going on, I'd be grateful. Thank you.
PS: I should also emphasize that as per this step gunicorn was worked out of the requirements, so unlike many questions similar to this, gunicorn is not supposed to be part of the picture.
(venv)John#JOHN-PC ~/python-getting-started (master)
$ foreman start web
16:06:13 web.1 | started with pid 24536
16:06:13 web.1 | Traceback (most recent call last):
16:06:13 web.1 | File "manage.py", line 10, in <module>
16:06:13 web.1 | execute_from_command_line(sys.argv)
16:06:13 web.1 | File "c:\Users\John\python-getting-started\venv\lib\site-packages\django\core\management\__init__.py", line 399, in execute_from_command_line
16:06:13 web.1 | utility.execute()
16:06:13 web.1 | File "c:\Users\John\python-getting-started\venv\lib\site-packages\django\core\management\__init__.py", line 392, in execute
16:06:13 web.1 | self.fetch_command(subcommand).run_from_argv(self.argv)
16:06:13 web.1 | File "c:\Users\John\python-getting-started\venv\lib\site-packages\django\core\management\base.py", line 242, in run_from_argv
16:06:13 web.1 | self.execute(*args, **options.__dict__)
16:06:13 web.1 | File "c:\Users\John\python-getting-started\venv\lib\site-packages\django\core\management\base.py", line 280, in execute
16:06:13 web.1 | translation.activate('en-us')
16:06:13 web.1 | File "c:\Users\John\python-getting-started\venv\lib\site-packages\django\utils\translation\__init__.py", line 130, in activate
16:06:13 web.1 | return _trans.activate(language)
16:06:13 web.1 | File "c:\Users\John\python-getting-started\venv\lib\site-packages\django\utils\translation\trans_real.py", line 188, in activate
16:06:13 web.1 | _active.value = translation(language)
16:06:13 web.1 | File "c:\Users\John\python-getting-started\venv\lib\site-packages\django\utils\translation\trans_real.py", line 177, in translation
16:06:13 web.1 | default_translation = _fetch(settings.LANGUAGE_CODE)
16:06:13 web.1 | File "c:\Users\John\python-getting-started\venv\lib\site-packages\django\utils\translation\trans_real.py", line 159, in _fetch
16:06:13 web.1 | app = import_module(appname)
16:06:13 web.1 | exited with code 1
16:06:13 system | sending SIGKILL to all processes
16:06:13 | File "c:\Users\John\python-getting-started\venv\lib\site -packages\django\utils\importlib.py", line 40, in import_module
Related
Having problems trying to set a secret key inside an .env instead of the settings.py file
When I run the heroku config I get the secret key
(portfolio) PS C:\Users\arund\Desktop\Code\Django\portfolio-project> heroku config:get SECRET_KEY
value
When I run the following I get errors.
(portfolio) PS C:\Users\arund\Desktop\Code\Django\portfolio-project> heroku local
[OKAY] Loaded ENV .env File as KEY=VALUE Format
1:53:57 PM web.1 | Traceback (most recent call last):
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\manage.py", line 22, in <module>
1:53:57 PM web.1 | main()
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\manage.py", line 18, in main
1:53:57 PM web.1 | execute_from_command_line(sys.argv)
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\venv\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
1:53:57 PM web.1 | utility.execute()
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute
1:53:57 PM web.1 | django.setup()
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\venv\lib\site-packages\django\__init__.py", line 24, in setup
1:53:57 PM web.1 | apps.populate(settings.INSTALLED_APPS)
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\venv\lib\site-packages\django\apps\registry.py", line 122, in populate
1:53:57 PM web.1 | app_config.ready()
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\venv\lib\site-packages\django\contrib\admin\apps.py", line 27, in ready
1:53:57 PM web.1 | self.module.autodiscover()
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\venv\lib\site-packages\django\contrib\admin\__init__.py", line 24, in autodiscover
1:53:57 PM web.1 | autodiscover_modules('admin', register_to=site)
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\venv\lib\site-packages\django\utils\module_loading.py", line 47, in autodiscover_modules
1:53:57 PM web.1 | import_module('%s.%s' % (app_config.name, module_to_search))
1:53:57 PM web.1 | File "C:\Python39\lib\importlib\__init__.py", line 127, in import_module
1:53:57 PM web.1 | return _bootstrap._gcd_import(name[level:], package, level)
1:53:57 PM web.1 | File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
1:53:57 PM web.1 | File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
1:53:57 PM web.1 | File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
1:53:57 PM web.1 | File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
1:53:57 PM web.1 | File "<frozen importlib._bootstrap_external>", line 790, in exec_module
1:53:57 PM web.1 | File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\venv\lib\site-packages\django\contrib\auth\admin.py", line 6, in <module>
1:53:57 PM web.1 | from django.contrib.auth.forms import (
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\venv\lib\site-packages\django\contrib\auth\forms.py", line 11, in <module>
1:53:57 PM web.1 | from django.contrib.auth.tokens import default_token_generator
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\venv\lib\site-packages\django\contrib\auth\tokens.py", line 117, in <module>
1:53:57 PM web.1 | default_token_generator = PasswordResetTokenGenerator()
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\venv\lib\site-packages\django\contrib\auth\tokens.py", line 18, in __init__
1:53:57 PM web.1 | self.secret = self.secret or settings.SECRET_KEY
1:53:57 PM web.1 | File "C:\Users\arund\Desktop\Code\Django\portfolio-project\venv\lib\site-packages\django\conf\__init__.py", line 90, in __getattr__
1:53:57 PM web.1 | raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
1:53:57 PM web.1 | django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
[DONE] Killing all processes with signal SIGINT
1:53:57 PM web.1 Exited with exit code null
Procfile
Django doesn't magically apply environment variables to your settings. You need to do that yourself, e.g. via something like this in your settings.py:
import os
SECRET_KEY = os.getenv("SECRET_KEY", default="dev key")
In development, you can use a .env file to populate your environment, but that file should not be committed to version control. Ignore it, and use Heroku's config vars instead. They will be injected into your application's environment.
I have exactly followed this tutorial (http://docs.docker.com/compose/django/) but when doing docker-compose up I get this error:
$ docker-compose up
Recreating composeexample_db_1...
Recreating composeexample_web_1...
Attaching to composeexample_db_1, composeexample_web_1
db_1 | LOG: database system was shut down at 2015-07-27 16:17:21 UTC
db_1 | LOG: MultiXact member wraparound protections are now enabled
db_1 | LOG: database system is ready to accept connections
db_1 | LOG: autovacuum launcher started
web_1 | Performing system checks...
web_1 |
web_1 | System check identified no issues (0 silenced).
web_1 | Unhandled exception in thread started by <function wrapper at 0x7f43f0126ed8>
web_1 | Traceback (most recent call last):
web_1 | File "/usr/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 225, in wrapper
web_1 | fn(*args, **kwargs)
web_1 | File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 112, in inner_run
web_1 | self.check_migrations()
web_1 | File "/usr/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 164, in check_migrations
web_1 | executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS])
web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/migrations/executor.py", line 19, in __init__
web_1 | self.loader = MigrationLoader(self.connection)
web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 47, in __init__
web_1 | self.build_graph()
web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/migrations/loader.py", line 182, in build_graph
web_1 | self.applied_migrations = recorder.applied_migrations()
web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 59, in applied_migrations
web_1 | self.ensure_schema()
web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/migrations/recorder.py", line 49, in ensure_schema
web_1 | if self.Migration._meta.db_table in self.connection.introspection.table_names(self.connection.cursor()):
web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 162, in cursor
web_1 | cursor = self.make_debug_cursor(self._cursor())
web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 135, in _cursor
web_1 | self.ensure_connection()
web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
web_1 | self.connect()
web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/utils.py", line 97, in __exit__
web_1 | six.reraise(dj_exc_type, dj_exc_value, traceback)
web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 130, in ensure_connection
web_1 | self.connect()
web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/backends/base/base.py", line 119, in connect
web_1 | self.connection = self.get_new_connection(conn_params)
web_1 | File "/usr/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 176, in get_new_connection
web_1 | connection = Database.connect(**conn_params)
web_1 | File "/usr/local/lib/python2.7/site-packages/psycopg2/__init__.py", line 164, in connect
web_1 | conn = _connect(dsn, connection_factory=connection_factory, async=async)
web_1 | django.db.utils.OperationalError: could not connect to server: No route to host
web_1 | Is the server running on host "db" (172.17.0.19) and accepting
web_1 | TCP/IP connections on port 5432?
Now, this only happens on my Fedora 21 system(kernel=4.0.4-202.fc21.x86_64) but when I spin up an Ubuntu instance in Virtualbox, it works just fine.
Any pointers?
I've run into the same issue and FWIW if you run the same command again then it works. It's almost as if "docker-compose up" brings up two containers at the same time and the django app container tries to run while postgres container is still being set up? It's mad confusing. :*(
UPDATE:
It seems that my suspicion was right, have a read at https://github.com/docker/compose/issues/374 .
Somewhat crude but a simple workaround to this race condition is to let django app container to sleep for a few seconds before running the command, so that the services that these containers depend on, e.g. PostgreSQL, are ready to accept connections. For example:
command: bash -c "sleep 3 && python manage.py runserver 0.0.0.0:8000" under django service in your yml file for docker-compose.
Another alternative is to run the django service with gunicorn or uwsgi which doesn't seem to instantiate the django application until request is received.
Hope this helps others currently fighting with docker.
I am trying to push my project into heroku and I am following these instructions:
https://devcenter.heroku.com/articles/getting-started-with-django
I am currently stuck on the part the says foreman start
I get this error: --> full error http://dpaste.com/3Y213Y2
(boothie.0.1)MTVL1289dd026:HerokuBoothie bli1$ foreman start
14:59:05 web.1 | started with pid 58353
14:59:05 web.1 | [2014-12-09 14:59:05 -0800] [58353] [INFO] Starting gunicorn 19.1.1
14:59:05 web.1 | [2014-12-09 14:59:05 -0800] [58353] [INFO] Listening at: http://0.0.0.0:5000 (58353)
14:59:05 web.1 | [2014-12-09 14:59:05 -0800] [58353] [INFO] Using worker: sync
14:59:05 web.1 | [2014-12-09 14:59:05 -0800] [58356] [INFO] Booting worker with pid: 58356
14:59:05 web.1 | [2014-12-09 14:59:05 -0800] [58356] [ERROR] Exception in worker process:
14:59:05 web.1 | Traceback (most recent call last):
14:59:05 web.1 | File "/Users/bli1/Development/Django/HerokuBoothie/boothie.0.1/lib/python2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
14:59:05 web.1 | worker.init_process()
14:59:05 web.1 | File "/Users/bli1/Development/Django/HerokuBoothie/boothie.0.1/lib/python2.7/site-packages/gunicorn/workers/base.py", line 114, in init_process
14:59:05 web.1 | self.wsgi = self.app.wsgi()
14:59:05 web.1 | File "/Users/bli1/Development/Django/HerokuBoothie/boothie.0.1/lib/python2.7/site-packages/gunicorn/app/base.py", line 66, in wsgi
14:59:05 web.1 | self.callable = self.load()
14:59:05 web.1 | File "/Users/bli1/Development/Django/HerokuBoothie/boothie.0.1/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
14:59:05 web.1 | return self.load_wsgiapp()
14:59:05 web.1 | File "/Users/bli1/Development/Django/HerokuBoothie/boothie.0.1/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
14:59:05 web.1 | return util.import_app(self.app_uri)
14:59:05 web.1 | File "/Users/bli1/Development/Django/HerokuBoothie/boothie.0.1/lib/python2.7/site-packages/gunicorn/util.py", line 356, in import_app
14:59:05 web.1 | __import__(module)
14:59:05 web.1 | ImportError: No module named HerokuBoothie.wsgi
Here is a picture of my project structure. The project is located inside a directory called HerokuBoothie.
Profile:
web: gunicorn HerokuBoothie.wsgi --log-file -
I think it's caused by your project structure; if you follow the heroku tutorial onto the point you have error (foreman start part), your directory structure would look like this:
hellodjango/
manage.py
Procfile
hellodjango/
__init__.py
settings.py
urls.py
wsgi.py
venv/
bin/
include/
lib/
You can see the structure you have is a bit different, there's an additional HerokuBoothie directory in your structure. I think restructure your project (something like mv ~/Development/Django/HerokuBoothie/HerokuBoothie/* ~/Development/Django/HerokuBoothie and remove the empty HerokuBoothie dir) would solve this issue, but you might have to change some codes if you use absolute paths in your codes.
You have to set the pythonpath as your HerokuBoothie module is located in another folder:
web: gunicorn HerokuBoothie.wsgi --pythonpath ../HerokuBoothie --log-file -
Using the following tutorials and github templates here, here, and here , I've spent the better part of the evening wrestling with django and mezzanine. Right now I've got a mezzanine-project, called uccdev which is working nicely when I run python manage.py runserver.
Now, I want to use gunicorn and foreman to get work with thing, so that I can later upload my projects to heroku.
According to Josh Finnie,
Adding the below Procfile got Mezzanine running on Gunicorn and successfully got Heroku to serve my static files. First if runs collectstatic to insure that all the static media is in the appropriate place within your app, and second it runs the Gunicorn server.
web: python manage.py collectstatic --noinput; python manage.py run_gunicorn -b 0.0.0.0:$PORT
I added gunicorn as an application in my settings.py, but every time I run foreman start in the terminal it shuts down immediately with the following error message.
Pythoness-998:uccdev gersande$ foreman start
01:02:45 web.1 | started with pid 7592
01:02:45 web.1 | /usr/local/lib/python2.7/site-packages/mezzanine/utils/conf.py:48: UserWarning: You haven't defined the ALLOWED_HOSTS settings, which Django 1.5 requires. Will fall back to the domains configured as sites.
01:02:45 web.1 | warn("You haven't defined the ALLOWED_HOSTS settings, which "
01:02:46 web.1 | 0 static files copied, 549 unmodified.
01:02:46 web.1 | /usr/local/lib/python2.7/site-packages/mezzanine/utils/conf.py:48: UserWarning: You haven't defined the ALLOWED_HOSTS settings, which Django 1.5 requires. Will fall back to the domains configured as sites.
01:02:46 web.1 | warn("You haven't defined the ALLOWED_HOSTS settings, which "
01:02:46 web.1 | 2013-12-23 01:02:46 [7594] [INFO] Starting gunicorn 18.0
01:02:46 web.1 | 2013-12-23 01:02:46 [7594] [INFO] Listening at: http://0.0.0.0:5000 (7594)
01:02:46 web.1 | 2013-12-23 01:02:46 [7594] [INFO] Using worker: sync
01:02:46 web.1 | 2013-12-23 01:02:46 [7597] [INFO] Booting worker with pid: 7597
01:02:46 web.1 | 2013-12-23 01:02:46 [7597] [ERROR] Exception in worker process:
01:02:46 web.1 | Traceback (most recent call last):
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
01:02:46 web.1 | worker.init_process()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
01:02:46 web.1 | self.wsgi = self.app.wsgi()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
01:02:46 web.1 | self.callable = self.load()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 142, in load
01:02:46 web.1 | return mod.make_command_wsgi_application(self.admin_media_path)
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 113, in make_command_wsgi_application
01:02:46 web.1 | reload_django_settings()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 109, in reload_django_settings
01:02:46 web.1 | logging_config_func(settings.LOGGING)
01:02:46 web.1 | File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 803, in dictConfig
01:02:46 web.1 | dictConfigClass(config).configure()
01:02:46 web.1 | File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 509, in configure
01:02:46 web.1 | raise ValueError("dictionary doesn't specify a version")
01:02:46 web.1 | ValueError: dictionary doesn't specify a version
01:02:46 web.1 | Traceback (most recent call last):
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
01:02:46 web.1 | worker.init_process()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
01:02:46 web.1 | self.wsgi = self.app.wsgi()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
01:02:46 web.1 | self.callable = self.load()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/djangoapp.py", line 142, in load
01:02:46 web.1 | return mod.make_command_wsgi_application(self.admin_media_path)
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 113, in make_command_wsgi_application
01:02:46 web.1 | reload_django_settings()
01:02:46 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/django_wsgi.py", line 109, in reload_django_settings
01:02:46 web.1 | logging_config_func(settings.LOGGING)
01:02:46 web.1 | File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 803, in dictConfig
01:02:46 web.1 | dictConfigClass(config).configure()
01:02:46 web.1 | File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 509, in configure
01:02:46 web.1 | raise ValueError("dictionary doesn't specify a version")
01:02:46 web.1 | ValueError: dictionary doesn't specify a version
01:02:46 web.1 | 2013-12-23 01:02:46 [7597] [INFO] Worker exiting (pid: 7597)
01:02:46 web.1 | 2013-12-23 01:02:46 [7594] [INFO] Shutting down: Master
01:02:46 web.1 | 2013-12-23 01:02:46 [7594] [INFO] Reason: Worker failed to boot.
01:02:46 web.1 | exited with code 3
01:02:46 system | sending SIGTERM to all processes
SIGTERM received
Any thoughts how to specify a version for the dictionary?
From user scum's answer - Correct way of creating supervisord script for gunicorn? Django 1.6
I added the following to my settings.py:
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
}
I'm following Getting Started with Django on Heroku tutorial
When I'm trying to run Django app on the Gunicorn using Foreman, i get next error traceback:
09:23:33 web.1 | started with pid 7012
09:23:34 web.1 | 2013-05-06 09:23:34 [7012] [INFO] Starting gunicorn 0.17.2
09:23:34 web.1 | 2013-05-06 09:23:34 [7012] [INFO] Listening at: `http://0.0.0.0:5000` (7012)
09:23:34 web.1 | 2013-05-06 09:23:34 [7012] [INFO] Using worker: sync
09:23:34 web.1 | 2013-05-06 09:23:34 [7015] [INFO] Booting worker with pid: 7015
09:23:34 web.1 | 2013-05-06 09:23:34 [7015] [ERROR] Exception in worker process:
09:23:34 web.1 | Traceback (most recent call last):
09:23:34 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 485, in spawn_worker
09:23:34 web.1 | worker.init_process()
09:23:34 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_process
09:23:34 web.1 | self.wsgi = self.app.wsgi()
09:23:34 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 103, in wsgi
09:23:34 web.1 | self.callable = self.load()
09:23:34 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 25, in load
09:23:34 web.1 | return util.import_app(self.app_uri)
09:23:34 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/util.py", line 372, in import_app
09:23:34 web.1 | __import__(module)
09:23:34 web.1 | File "/Users/cosmicMan66/DjangoDev/hepcat_server/hepcat_server/wsgi.py", line 27, in <module>
09:23:34 web.1 | from django.core.wsgi import get_wsgi_application
09:23:34 web.1 | ImportError: No module named django.core.wsgi
09:23:34 web.1 | Traceback (most recent call last):
09:23:34 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/arbiter.py", line 485, in spawn_worker
09:23:34 web.1 | worker.init_process()
09:23:34 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/workers/base.py", line 100, in init_process
09:23:34 web.1 | self.wsgi = self.app.wsgi()
09:23:34 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/base.py", line 103, in wsgi
09:23:34 web.1 | self.callable = self.load()
09:23:34 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 25, in load
09:23:34 web.1 | return util.import_app(self.app_uri)
09:23:34 web.1 | File "/usr/local/lib/python2.7/site-packages/gunicorn/util.py", line 372, in import_app
09:23:34 web.1 | __import__(module)
09:23:34 web.1 | File "/Users/cosmicMan66/DjangoDev/hepcat_server/hepcat_server/wsgi.py", line 27, in <module>
09:23:34 web.1 | from django.core.wsgi import get_wsgi_application
09:23:34 web.1 | ImportError: No module named django.core.wsgi
09:23:34 web.1 | 2013-05-06 09:23:34 [7015] [INFO] Worker exiting (pid: 7015)
09:23:35 web.1 | 2013-05-06 09:23:35 [7012] [INFO] Shutting down: Master
09:23:35 web.1 | 2013-05-06 09:23:35 [7012] [INFO] Reason: Worker failed to boot.
09:23:35 web.1 | exited with code 3
09:23:35 system | sending SIGTERM to all processes
SIGTERM received
Procfile is located in the root directory of a project and contains:
web: gunicorn hepcat_server.wsgi
settings.py is located in hepcat_server directory
when I use $ python manage.py run_gunicorn
gunicorn starts successfully and I see default Django page
I had the same issue while following the Heroku setup page you were using. I found a solution on this page. I've copied it here for posterity:
In the root directory of your django project, create the Procfile file.
then write this on it web: sh -c "cd djangoproject && gunicorn
djangoproject.wsgi". then create another file called .env in the same
location, write DJANGO_SETTINGS_MODULE=djangoproject.settings into it,
this will help you setting the required env variable that cannot be
set in djangoproject.wsgi module. run foreman start in order to test.
What this does should be self explanatory giving the issue below.
When you deploy, after creating your application in heroku, set the
env variable with this command heroku config:set
DJANGO_SETTINGS_MODULE=djangoproject.settings, this is because the
deployment fails before the file djangoproject/djangoproject/wsgi.py
is run.
remember to replace "djangoproject" with the name of your django project.