Heroku Django错误运行应用程序

时间:2016-02-19 20:30:11

标签: python django heroku

所以我从这里和其他论坛尝试了很多东西,没有。所以请帮我解决这类问题。我是python和Django中的新手,我创建了一个小应用程序,它运行完美的 heroku local 命令但是一旦我把它放到服务器上我就无法运行它,这是我的追溯:

~ $ 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.
~ $ 

安装crispy_forms并运行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.
~ $ 

1 个答案:

答案 0 :(得分:2)

在您的应用程序的基本级目录中,您有一个requirements.txt文件,Heroku使用该文件来安装所有需要的库/包。

复制用于开发的环境的最简单方法是cd到该目录并运行pip freeze > requirements.txt。这将创建一个镜像您的开发环境的文件。提交并将该文件推送到Heroku,Heroku将安装这些包及其依赖项。

对于此特定错误,添加django-crispy-forms行将负责安装。

Heroku文档here