Нет модуля с именем django_heroku - PullRequest
0 голосов
/ 19 июня 2020

Я пытаюсь перенести свою базу данных на Heroku через:

heroku run python3 manage.py migrate

и получаю эту ошибку:

    Traceback (most recent call last):
  `File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/base.py", line 366, in execute
    self.check()
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/base.py", line 392, in check
    all_issues = self._run_checks(
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 63, in _run_checks
    issues = run_checks(tags=[Tags.database])
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/core/checks/database.py", line 9, in check_database_backends
    for conn in connections.all():
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/utils.py", line 222, in all
    return [self[alias] for alias in self]
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/utils.py", line 219, in __iter__
    return iter(self.databases)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/db/utils.py", line 153, in databases
    self._databases = settings.DATABASES
  File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 76, in __getattr__
    self._setup(name)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 63, in _setup
    self._wrapped = Settings(settings_module)
  File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 142, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/learning_log/settings.py", line 134, in <module>
    import django_heroku
ModuleNotFoundError: No module named 'django_heroku'
`

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "manage.py", line 21, in <module>
    main()


    File "manage.py", line 17, in main
        execute_from_command_line(sys.argv)
      File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
        utility.execute()
      File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
        self.fetch_command(subcommand).run_from_argv(self.argv)
      File "/app/.heroku/python/lib/python3.8/site-packages/django/core/management/base.py", line 341, in run_from_argv
        connections.close_all()
      File "/app/.heroku/python/lib/python3.8/site-packages/django/db/utils.py", line 225, in close_all
        for alias in self:
      File "/app/.heroku/python/lib/python3.8/site-packages/django/db/utils.py", line 219, in __iter__
        return iter(self.databases)
      File "/app/.heroku/python/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
        res = instance.__dict__[self.name] = self.func(instance)
      File "/app/.heroku/python/lib/python3.8/site-packages/django/db/utils.py", line 153, in databases
        self._databases = settings.DATABASES
      File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 76, in __getattr__
        self._setup(name)
      File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 63, in _setup
        self._wrapped = Settings(settings_module)
      File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 142, in __init__
        mod = importlib.import_module(self.SETTINGS_MODULE)
      File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
      File "<frozen importlib._bootstrap>", line 991, in _find_and_load
      File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 783, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/app/learning_log/settings.py", line 134, in <module>
        import django_heroku
    ModuleNotFoundError: No module named 'django_heroku'

Вот и мои требования. .txt содержимое файла:

    asgiref==3.2.7
beautifulsoup4==4.9.1
bleach==3.1.5
certifi==2020.4.5.2
chardet==3.0.4
dj-database-url==0.5.0
Django==3.0.6
django-bootstrap4==2.0.1
django-heroku==0.3.1
docutils==0.16
gunicorn==20.0.4
idna==2.9
keyring==21.2.1
packaging==20.4
pkginfo==1.5.0.1
psycopg2==2.8.5
psycopg2-binary==2.8.5
Pygments==2.6.1
pyparsing==2.4.7
pytz==2020.1
readme-renderer==26.0
requests==2.24.0
requests-toolbelt==0.9.1
six==1.15.0
soupsieve==2.0.1
sqlparse==0.3.1
tqdm==4.46.1
twine==3.1.1
urllib3==1.25.9
webencodings==0.5.1
whitenoise==5.1.0

Я новичок в Python Django и Heroku, я не понимаю, поскольку вы можете видеть, что пакеты установлены в моем файле, а также в моих настройках. py, поскольку я импортировал модуль и написал эту команду:

import django_heroku
django_heroku.settings(locals())

Вот что я получаю, когда запускаю логи heroku:

2020-06-18T23:28:32.458372+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2020-06-18T23:28:32.458372+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 142, in __init__
2020-06-18T23:28:32.458373+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2020-06-18T23:28:32.458373+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2020-06-18T23:28:32.458374+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-06-18T23:28:32.458374+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2020-06-18T23:28:32.458375+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2020-06-18T23:28:32.458375+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2020-06-18T23:28:32.458376+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2020-06-18T23:28:32.458376+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 783, in exec_module
2020-06-18T23:28:32.458377+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-06-18T23:28:32.458377+00:00 app[web.1]: File "/app/learning_log/settings.py", line 134, in <module>
2020-06-18T23:28:32.458378+00:00 app[web.1]: import django_heroku
2020-06-18T23:28:32.458378+00:00 app[web.1]: ModuleNotFoundError: No module named 'django_heroku'
2020-06-18T23:28:32.458490+00:00 app[web.1]: [2020-06-18 23:28:32 +0000] [9] [INFO] Worker exiting (pid: 9)
2020-06-18T23:28:32.515167+00:00 app[web.1]: [2020-06-18 23:28:32 +0000] [10] [ERROR] Exception in worker process
2020-06-18T23:28:32.515191+00:00 app[web.1]: Traceback (most recent call last):
2020-06-18T23:28:32.515204+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
2020-06-18T23:28:32.515206+00:00 app[web.1]: worker.init_process()
2020-06-18T23:28:32.515206+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 119, in init_process
2020-06-18T23:28:32.515206+00:00 app[web.1]: self.load_wsgi()
2020-06-18T23:28:32.515207+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/workers/base.py", line 144, in load_wsgi
2020-06-18T23:28:32.515207+00:00 app[web.1]: self.wsgi = self.app.wsgi()
2020-06-18T23:28:32.515220+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 67, in wsgi
2020-06-18T23:28:32.515221+00:00 app[web.1]: self.callable = self.load()
2020-06-18T23:28:32.515221+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 49, in load
2020-06-18T23:28:32.515221+00:00 app[web.1]: return self.load_wsgiapp()
2020-06-18T23:28:32.515221+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 39, in load_wsgiapp
2020-06-18T23:28:32.515222+00:00 app[web.1]: return util.import_app(self.app_uri)
2020-06-18T23:28:32.515222+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/util.py", line 358, in import_app
2020-06-18T23:28:32.515222+00:00 app[web.1]: mod = importlib.import_module(module)
2020-06-18T23:28:32.515223+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2020-06-18T23:28:32.515223+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-06-18T23:28:32.515223+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2020-06-18T23:28:32.515224+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2020-06-18T23:28:32.515224+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2020-06-18T23:28:32.515224+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2020-06-18T23:28:32.515224+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 783, in exec_module
2020-06-18T23:28:32.515225+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-06-18T23:28:32.515225+00:00 app[web.1]: File "/app/learning_log/wsgi.py", line 16, in <module>
2020-06-18T23:28:32.515225+00:00 app[web.1]: application = get_wsgi_application()
2020-06-18T23:28:32.515226+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
2020-06-18T23:28:32.515226+00:00 app[web.1]: django.setup(set_prefix=False)
2020-06-18T23:28:32.515226+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/__init__.py", line 19, in setup
2020-06-18T23:28:32.515227+00:00 app[web.1]: configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2020-06-18T23:28:32.515227+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 76, in __getattr__
2020-06-18T23:28:32.515227+00:00 app[web.1]: self._setup(name)
2020-06-18T23:28:32.515227+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 63, in _setup
2020-06-18T23:28:32.515228+00:00 app[web.1]: self._wrapped = Settings(settings_module)
2020-06-18T23:28:32.515228+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/django/conf/__init__.py", line 142, in __init__
2020-06-18T23:28:32.515228+00:00 app[web.1]: mod = importlib.import_module(self.SETTINGS_MODULE)
2020-06-18T23:28:32.515229+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/importlib/__init__.py", line 127, in import_module
2020-06-18T23:28:32.515229+00:00 app[web.1]: return _bootstrap._gcd_import(name[level:], package, level)
2020-06-18T23:28:32.515229+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
2020-06-18T23:28:32.515229+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 991, in _find_and_load
2020-06-18T23:28:32.515230+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
2020-06-18T23:28:32.515230+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
2020-06-18T23:28:32.515230+00:00 app[web.1]: File "<frozen importlib._bootstrap_external>", line 783, in exec_module
2020-06-18T23:28:32.515230+00:00 app[web.1]: File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
2020-06-18T23:28:32.515231+00:00 app[web.1]: File "/app/learning_log/settings.py", line 134, in <module>
2020-06-18T23:28:32.515231+00:00 app[web.1]: import django_heroku
2020-06-18T23:28:32.515231+00:00 app[web.1]: ModuleNotFoundError: No module named 'django_heroku'
2020-06-18T23:28:32.515360+00:00 app[web.1]: [2020-06-18 23:28:32 +0000] [10] [INFO] Worker exiting (pid: 10)
2020-06-18T23:28:32.563252+00:00 app[web.1]: Traceback (most recent call last):
2020-06-18T23:28:32.563500+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 209, in run
2020-06-18T23:28:32.563501+00:00 app[web.1]: self.sleep()
2020-06-18T23:28:32.563502+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 357, in sleep
2020-06-18T23:28:32.563503+00:00 app[web.1]: ready = select.select([self.PIPE[0]], [], [], 1.0)
2020-06-18T23:28:32.563503+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2020-06-18T23:28:32.563509+00:00 app[web.1]: self.reap_workers()
2020-06-18T23:28:32.563509+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2020-06-18T23:28:32.565281+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2020-06-18T23:28:32.565282+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2020-06-18T23:28:32.565283+00:00 app[web.1]: 
2020-06-18T23:28:32.565283+00:00 app[web.1]: During handling of the above exception, another exception occurred:
2020-06-18T23:28:32.565284+00:00 app[web.1]: 
2020-06-18T23:28:32.565294+00:00 app[web.1]: Traceback (most recent call last):
2020-06-18T23:28:32.565295+00:00 app[web.1]: File "/app/.heroku/python/bin/gunicorn", line 8, in <module>
2020-06-18T23:28:32.565296+00:00 app[web.1]: sys.exit(run())
2020-06-18T23:28:32.565297+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/wsgiapp.py", line 58, in run
2020-06-18T23:28:32.565297+00:00 app[web.1]: WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
2020-06-18T23:28:32.565298+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 228, in run
2020-06-18T23:28:32.565298+00:00 app[web.1]: super().run()
2020-06-18T23:28:32.565299+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/app/base.py", line 72, in run
2020-06-18T23:28:32.565299+00:00 app[web.1]: Arbiter(self).run()
2020-06-18T23:28:32.565299+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 229, in run
2020-06-18T23:28:32.565300+00:00 app[web.1]: self.halt(reason=inst.reason, exit_status=inst.exit_status)
2020-06-18T23:28:32.565300+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 342, in halt
2020-06-18T23:28:32.565300+00:00 app[web.1]: self.stop()
2020-06-18T23:28:32.565301+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 393, in stop
2020-06-18T23:28:32.565410+00:00 app[web.1]: time.sleep(0.1)
2020-06-18T23:28:32.565416+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 242, in handle_chld
2020-06-18T23:28:32.565647+00:00 app[web.1]: self.reap_workers()
2020-06-18T23:28:32.565668+00:00 app[web.1]: File "/app/.heroku/python/lib/python3.8/site-packages/gunicorn/arbiter.py", line 525, in reap_workers
2020-06-18T23:28:32.565996+00:00 app[web.1]: raise HaltServer(reason, self.WORKER_BOOT_ERROR)
2020-06-18T23:28:32.566074+00:00 app[web.1]: gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
2020-06-18T23:28:32.635048+00:00 heroku[web.1]: Process exited with status 1
2020-06-18T23:28:32.697976+00:00 heroku[web.1]: State changed from starting to crashed
2020-06-18T23:32:15.751593+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=frozen-lake-95981.herokuapp.com request_id=a7bcd78a-bc79-4da9-9e8e-102452995106 fwd="37.166.63.85" dyno= connect= service= status=503 bytes= protocol=https
2020-06-18T23:32:16.395228+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=frozen-lake-95981.herokuapp.com request_id=43c7f302-ee9b-41ff-a2a1-db00a6a91134 fwd="37.166.63.85" dyno= connect= service= status=503 bytes= protocol=https

Заранее спасибо за вашу помощь!

1 Ответ

0 голосов
/ 06 сентября 2020

Используйте следующие команды:

pip install psycopg2-binary
pip install django-on-heroku

После установки найдите папку django_on_heroku-1.0.1.dist-info , дополнительную информацию читайте в МЕТАДАННЫХ файл.

Две строки кода, которые нужно добавить в setting.py:

import django_on_heroku
django_on_heroku.settings(locals())
...