django daphne ModuleNotFoundError:'设置'

时间:2017-09-07 06:18:45

标签: python django heroku daphne

我使用频道制作了一个django项目。

我想部署它。因为我的项目使用频道,所以我应该设置基于 ASGI 的环境。

我推动了我的项目并取得了成功。所以我得到了URL地址。

https://demo-multichat.herokuapp.com

如您所见,应用程序错误已经发生。

我得到了记录。

$ heroku logs

2017-09-07T06:03:55.893921+00:00 app[worker.1]:     result = connection.blpop(list_names, timeout=self.blpop_timeout)
2017-09-07T06:03:55.893925+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/redis/client.py", line 1269, in blpop
2017-09-07T06:03:55.894950+00:00 app[worker.1]:     return self.execute_command('BLPOP', *keys)
2017-09-07T06:03:55.894954+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/redis/client.py", line 673, in execute_command
2017-09-07T06:03:55.895473+00:00 app[worker.1]:     connection.send_command(*args)
2017-09-07T06:03:55.895477+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/redis/connection.py", line 610, in send_command
2017-09-07T06:03:55.895972+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/redis/connection.py", line 585, in send_packed_command
2017-09-07T06:03:55.895968+00:00 app[worker.1]:     self.send_packed_command(self.pack_command(*args))
2017-09-07T06:03:55.896440+00:00 app[worker.1]:     self.connect()
2017-09-07T06:03:55.896444+00:00 app[worker.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/redis/connection.py", line 489, in connect
2017-09-07T06:03:55.896869+00:00 app[worker.1]:     raise ConnectionError(self._error_message(e))
2017-09-07T06:03:55.896892+00:00 app[worker.1]: redis.exceptions.ConnectionError: Error 111 connecting to localhost:6379. Connection refused.
2017-09-07T06:03:56.097153+00:00 heroku[worker.1]: Process exited with status 1
2017-09-07T06:04:35.728878+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=demo-multichat.herokuapp.com request_id=ae95450d-249f-46e4-af5e-fd69b3339fbd fwd="165.132.5.143" dyno= connect= service= status=503 bytes= protocol=http
2017-09-07T06:04:36.537336+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=demo-multichat.herokuapp.com request_id=5a48b0e9-0fae-46b2-9885-f1a8390b8eb9 fwd="165.132.5.143" dyno= connect= service= status=503 bytes= protocol=http
2017-09-07T06:04:37.170094+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=demo-multichat.herokuapp.com request_id=db7f5507-c748-4ae5-9718-379cacf3e8e1 fwd="165.132.5.143" dyno= connect= service= status=503 bytes= protocol=http
2017-09-07T06:05:50.020700+00:00 app[api]: Scaled to web@1:Free worker@1:Free by user juhyun1849@gmail.com
2017-09-07T06:05:56.482746+00:00 heroku[web.1]: Starting process with command `daphne multichat.asgi:channel_layer`
2017-09-07T06:05:59.257502+00:00 app[web.1]: Traceback (most recent call last):
2017-09-07T06:05:59.257522+00:00 app[web.1]:   File "/app/.heroku/python/bin/daphne", line 11, in <module>
2017-09-07T06:05:59.257631+00:00 app[web.1]:     sys.exit(CommandLineInterface.entrypoint())
2017-09-07T06:05:59.257633+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/daphne/cli.py", line 144, in entrypoint
2017-09-07T06:05:59.257753+00:00 app[web.1]:     cls().run(sys.argv[1:])
2017-09-07T06:05:59.257755+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/daphne/cli.py", line 174, in run
2017-09-07T06:05:59.257875+00:00 app[web.1]:     channel_layer = importlib.import_module(module_path)
2017-09-07T06:05:59.257876+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2017-09-07T06:05:59.257982+00:00 app[web.1]:     return _bootstrap._gcd_import(name[level:], package, level)
2017-09-07T06:05:59.257983+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 978, in _gcd_import
2017-09-07T06:05:59.258104+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 961, in _find_and_load
2017-09-07T06:05:59.258179+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
2017-09-07T06:05:59.258250+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
2017-09-07T06:05:59.258318+00:00 app[web.1]:   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2017-09-07T06:05:59.258403+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
2017-09-07T06:05:59.258472+00:00 app[web.1]:   File "./multichat/asgi.py", line 11, in <module>
2017-09-07T06:05:59.258560+00:00 app[web.1]:     channel_layer = get_channel_layer()
2017-09-07T06:05:59.258561+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/channels/asgi.py", line 115, in get_channel_layer
2017-09-07T06:05:59.258664+00:00 app[web.1]:     django.setup(set_prefix=False)
2017-09-07T06:05:59.258666+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 22, in setup
2017-09-07T06:05:59.258744+00:00 app[web.1]:     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2017-09-07T06:05:59.258748+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
2017-09-07T06:05:59.258867+00:00 app[web.1]:     self._setup(name)
2017-09-07T06:05:59.258869+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 41, in _setup
2017-09-07T06:05:59.258935+00:00 app[web.1]:     self._wrapped = Settings(settings_module)
2017-09-07T06:05:59.258936+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 110, in __init__
2017-09-07T06:05:59.259050+00:00 app[web.1]:     mod = importlib.import_module(self.SETTINGS_MODULE)
2017-09-07T06:05:59.259052+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2017-09-07T06:05:59.259136+00:00 app[web.1]:     return _bootstrap._gcd_import(name[level:], package, level)
2017-09-07T06:05:59.259137+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 978, in _gcd_import
2017-09-07T06:05:59.259222+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 961, in _find_and_load
2017-09-07T06:05:59.259287+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
2017-09-07T06:05:59.259356+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
2017-09-07T06:05:59.259438+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 978, in _gcd_import
2017-09-07T06:05:59.259504+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 961, in _find_and_load
2017-09-07T06:05:59.259570+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
2017-09-07T06:05:59.259643+00:00 app[web.1]: ModuleNotFoundError: No module named 'settings'
2017-09-07T06:05:59.407057+00:00 heroku[web.1]: State changed from starting to crashed
2017-09-07T06:05:59.409405+00:00 heroku[web.1]: State changed from crashed to starting
2017-09-07T06:05:59.392197+00:00 heroku[web.1]: Process exited with status 1
2017-09-07T06:06:04.442747+00:00 heroku[web.1]: Starting process with command `daphne multichat.asgi:channel_layer`
2017-09-07T06:06:06.999728+00:00 app[web.1]: Traceback (most recent call last):
2017-09-07T06:06:06.999748+00:00 app[web.1]:   File "/app/.heroku/python/bin/daphne", line 11, in <module>
2017-09-07T06:06:06.999910+00:00 app[web.1]:     sys.exit(CommandLineInterface.entrypoint())
2017-09-07T06:06:06.999915+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/daphne/cli.py", line 144, in entrypoint
2017-09-07T06:06:07.000097+00:00 app[web.1]:     cls().run(sys.argv[1:])
2017-09-07T06:06:07.000101+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/daphne/cli.py", line 174, in run
2017-09-07T06:06:07.000291+00:00 app[web.1]:     channel_layer = importlib.import_module(module_path)
2017-09-07T06:06:07.000294+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2017-09-07T06:06:07.000469+00:00 app[web.1]:     return _bootstrap._gcd_import(name[level:], package, level)
2017-09-07T06:06:07.000667+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 961, in _find_and_load
2017-09-07T06:06:07.000472+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 978, in _gcd_import
2017-09-07T06:06:07.000786+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
2017-09-07T06:06:07.000900+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
2017-09-07T06:06:07.001008+00:00 app[web.1]:   File "<frozen importlib._bootstrap_external>", line 678, in exec_module
2017-09-07T06:06:07.001159+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
2017-09-07T06:06:07.001282+00:00 app[web.1]:   File "./multichat/asgi.py", line 11, in <module>
2017-09-07T06:06:07.001414+00:00 app[web.1]:     channel_layer = get_channel_layer()
2017-09-07T06:06:07.001418+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/channels/asgi.py", line 115, in get_channel_layer
2017-09-07T06:06:07.001585+00:00 app[web.1]:     django.setup(set_prefix=False)
2017-09-07T06:06:07.001588+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/__init__.py", line 22, in setup
2017-09-07T06:06:07.001725+00:00 app[web.1]:     configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
2017-09-07T06:06:07.001728+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
2017-09-07T06:06:07.001873+00:00 app[web.1]:     self._setup(name)
2017-09-07T06:06:07.001876+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 41, in _setup
2017-09-07T06:06:07.002020+00:00 app[web.1]:     self._wrapped = Settings(settings_module)
2017-09-07T06:06:07.002024+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/site-packages/django/conf/__init__.py", line 110, in __init__
2017-09-07T06:06:07.002184+00:00 app[web.1]:     mod = importlib.import_module(self.SETTINGS_MODULE)
2017-09-07T06:06:07.002352+00:00 app[web.1]:     return _bootstrap._gcd_import(name[level:], package, level)
2017-09-07T06:06:07.002188+00:00 app[web.1]:   File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
2017-09-07T06:06:07.002355+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 978, in _gcd_import
2017-09-07T06:06:07.002479+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 961, in _find_and_load
2017-09-07T06:06:07.002593+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
2017-09-07T06:06:07.002707+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
2017-09-07T06:06:07.002814+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 978, in _gcd_import
2017-09-07T06:06:07.002923+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 961, in _find_and_load
2017-09-07T06:06:07.003034+00:00 app[web.1]:   File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
2017-09-07T06:06:07.003154+00:00 app[web.1]: ModuleNotFoundError: No module named 'settings'
2017-09-07T06:06:07.152538+00:00 heroku[web.1]: Process exited with status 1
2017-09-07T06:06:07.168247+00:00 heroku[web.1]: State changed from starting to crashed
2017-09-07T06:06:07.856101+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=demo-multichat.herokuapp.com request_id=f934301e-6f75-43bc-8e2d-76959a638d5c fwd="165.132.5.143" dyno= connect= service= status=503 bytes= protocol=http
2017-09-07T06:06:08.042260+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=demo-multichat.herokuapp.com request_id=cd37f077-714e-4739-abb7-01b8400245aa fwd="165.132.5.143" dyno= connect= service= status=503 bytes= protocol=http
2017-09-07T06:06:08.453060+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=demo-multichat.herokuapp.com request_id=b33103b3-167d-4dea-989c-c19c5e7598ad fwd="165.132.5.143" dyno= connect= service= status=503 bytes= protocol=http

我认为Procfile出了问题。以下是我的Procfile设置。

  

web:daphne multichat.asgi:channel_layer

     

worker:python manage.py runworker

在我的本地终端,我执行了每一行。

第一个 $ python manage.py runworker

2017-09-07 15:12:43,889 - INFO - runworker - Using single-threaded worker.
2017-09-07 15:12:43,889 - INFO - runworker - Running worker against channel layer default (asgi_redis.core.RedisChannelLayer)
2017-09-07 15:12:43,889 - INFO - worker - Listening on channels chat.receive, http.request, websocket.connect, websocket.disconnect, websocket.receive

很好。好。

第二 $ daphne multichat.asgi:channel_layer

Traceback (most recent call last):
  File "/home/juhyun-park/PyVirt/Virt1/bin/daphne", line 11, in <module>
    sys.exit(CommandLineInterface.entrypoint())
  File "/home/juhyun-park/PyVirt/Virt1/lib/python3.6/site-packages/daphne/cli.py", line 144, in entrypoint
    cls().run(sys.argv[1:])
  File "/home/juhyun-park/PyVirt/Virt1/lib/python3.6/site-packages/daphne/cli.py", line 174, in run
    channel_layer = importlib.import_module(module_path)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "./multichat/asgi.py", line 11, in <module>
    channel_layer = get_channel_layer()
  File "/home/juhyun-park/PyVirt/Virt1/lib/python3.6/site-packages/channels/asgi.py", line 115, in get_channel_layer
    django.setup(set_prefix=False)
  File "/home/juhyun-park/PyVirt/Virt1/lib/python3.6/site-packages/django/__init__.py", line 22, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/home/juhyun-park/PyVirt/Virt1/lib/python3.6/site-packages/django/conf/__init__.py", line 56, in __getattr__
    self._setup(name)
  File "/home/juhyun-park/PyVirt/Virt1/lib/python3.6/site-packages/django/conf/__init__.py", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/juhyun-park/PyVirt/Virt1/lib/python3.6/site-packages/django/conf/__init__.py", line 110, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 936, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'settings'

我收到了错误消息。

我该如何解决这个问题?我需要你的帮助。

如果您需要我的项目源代码,我将github存储库url留作评论。

0 个答案:

没有答案