简体   繁体   中英

Heroku Django error run the app

So I have tried a lot of stuff from here and from other forums, NOTHING. So please help me to resolve this kind of stuff. I am very new in python and in Django, I have created a small app, it runs perfect with command but once I put it to the server I cant run it, this is my traceback: 命令完美配合,但是一旦将其放到服务器上就无法运行,这是我的回溯:

~ $ gunicorn trydjango18.wsgi:application
2016-02-19 20:22:50 [17] [INFO] Starting gunicorn 18.0
2016-02-19 20:22:50 [17] [INFO] Listening at: http://0.0.0.0:56762 (17)
2016-02-19 20:22:50 [17] [INFO] Using worker: sync
2016-02-19 20:22:50 [22] [INFO] Booting worker with pid: 22
2016-02-19 20:22:50 [22] [ERROR] Exception in worker process:
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
    worker.init_process()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
    self.wsgi = self.app.wsgi()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
    self.callable = self.load()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
    return self.load_wsgiapp()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
    __import__(module)
  File "/app/trydjango18/wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
    django.setup()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named crispy_forms
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
    worker.init_process()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
    self.wsgi = self.app.wsgi()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
    self.callable = self.load()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
    return self.load_wsgiapp()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
    __import__(module)
  File "/app/trydjango18/wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
    django.setup()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named crispy_forms
2016-02-19 20:22:50 [22] [INFO] Worker exiting (pid: 22)
2016-02-19 20:22:50 [17] [INFO] Shutting down: Master
2016-02-19 20:22:50 [17] [INFO] Reason: Worker failed to boot.
~ $ 

After I installed crispy_forms and ran heroku run python manage.py collectstatic --noinput Running python manage.py collectstatic --noinput on blooming-wave-82922... !!! ▸ Cannot run more than 1 Free size dynos. heroku run python manage.py collectstatic --noinput Running python manage.py collectstatic --noinput on blooming-wave-82922... !!! ▸ Cannot run more than 1 Free size dynos.

~ $ gunicorn trydjango18.wsgi:application
2016-02-19 22:36:07 [21] [INFO] Starting gunicorn 18.0
2016-02-19 22:36:07 [21] [INFO] Listening at: http://0.0.0.0:10012 (21)
2016-02-19 22:36:07 [21] [INFO] Using worker: sync
2016-02-19 22:36:07 [26] [INFO] Booting worker with pid: 26
2016-02-19 22:36:07 [26] [ERROR] Exception in worker process:
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
    worker.init_process()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
    self.wsgi = self.app.wsgi()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
    self.callable = self.load()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
    return self.load_wsgiapp()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
    __import__(module)
  File "/app/trydjango18/wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
    django.setup()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named registration
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker
    worker.init_process()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process
    self.wsgi = self.app.wsgi()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/base.py", line 114, in wsgi
    self.callable = self.load()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 62, in load
    return self.load_wsgiapp()
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 49, in load_wsgiapp
    return util.import_app(self.app_uri)
  File "/app/.heroku/python/lib/python2.7/site-packages/gunicorn/util.py", line 354, in import_app
    __import__(module)
  File "/app/trydjango18/wsgi.py", line 16, in <module>
    application = get_wsgi_application()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
    django.setup()
  File "/app/.heroku/python/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/app/.heroku/python/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/app/.heroku/python/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: No module named registration
2016-02-19 22:36:07 [26] [INFO] Worker exiting (pid: 26)
2016-02-19 22:36:08 [21] [INFO] Shutting down: Master
2016-02-19 22:36:08 [21] [INFO] Reason: Worker failed to boot.
~ $ 

In your base level directory for your application, you have a requirements.txt file that Heroku uses to install all needed libraries/packages.

The easiest way to replicate the environment you are using for development is to cd in to that dir and run pip freeze > requirements.txt . This will create a file that mirrors your development environment. Commit and push that file to Heroku, and Heroku will install those packages and their dependencies.

For this particular error, adding a line with django-crispy-forms will take care of the installation.

Heroku documentation here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM