gpt4 book ai didi

python - 尝试运行具有 django -channels 的服务器时出现错误

转载 作者:行者123 更新时间:2023-12-01 09:33:42 25 4
gpt4 key购买 nike

我试图在我的 django-project 中使用 django-channels 并在尝试运行服务器时收到此错误。我正在按照本教程构建聊天应用程序。

https://gearheart.io/blog/creating-a-chat-with-django-channels/

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fb7aa2b1e18>
Traceback (most recent call last):
File "/home/praneet/pral/jagrit/newenv/lib/python3.4/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/praneet/pral/jagrit/newenv/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 112, in inner_run
autoreload.raise_last_exception()
File "/home/praneet/pral/jagrit/newenv/lib/python3.4/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "/home/praneet/pral/jagrit/newenv/lib/python3.4/site-packages/django/core/management/__init__.py", line 327, in execute
autoreload.check_errors(django.setup)()
File "/home/praneet/pral/jagrit/newenv/lib/python3.4/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/praneet/pral/jagrit/newenv/lib/python3.4/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/praneet/pral/jagrit/newenv/lib/python3.4/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/home/praneet/pral/jagrit/newenv/lib/python3.4/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/home/praneet/pral/jagrit/newenv/lib/python3.4/site-packages/channels/apps.py", line 6, in <module>
import daphne.server # noqa
File "/home/praneet/pral/jagrit/newenv/lib/python3.4/site-packages/daphne/server.py", line 192
async def handle_reply(self, protocol, message):
^
SyntaxError: invalid syntax

最佳答案

channel 2 dropped support适用于 Python 2.7 和 3.4。现在需要 Python 3.5 或 3.6。

async def Python 3.5 中添加了该语句。由于您使用的是 Python 3.4,因此出现语法错误。

关于python - 尝试运行具有 django -channels 的服务器时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49728732/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com