我正在尝试使用 django 通道,但它不断抛出错误



我试图在我的django项目中实现django通道应用程序。但是每当我把channels应用放到django settings.py中,它就会抛出如下错误

Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "E:sunil_sachinSSMOS_envlibsite-packagesdjangocoremanagement__init__.py", line 419, in execute_from_command_line
utility.execute()
File "E:sunil_sachinSSMOS_envlibsite-packagesdjangocoremanagement__init__.py", line 395, in execute
django.setup()
File "E:sunil_sachinSSMOS_envlibsite-packagesdjango__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "E:sunil_sachinSSMOS_envlibsite-packagesdjangoappsregistry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "E:sunil_sachinSSMOS_envlibsite-packagesdjangoappsconfig.py", line 124, in create
mod = import_module(mod_path)
File "C:UsersAdminAppDataLocalProgramsPythonPython36libimportlib__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 "E:sunil_sachinSSMOS_envlibsite-packageschannelsapps.py", line 4, in <module>
import daphne.server
File "E:sunil_sachinSSMOS_envlibsite-packagesdaphneserver.py", line 5, in <module>
from twisted.internet import asyncioreactor  # isort:skip
File "E:sunil_sachinSSMOS_envlibsite-packagestwistedinternetasyncioreactor.py", line 16, in <module>
from twisted.logger import Logger
File "E:sunil_sachinSSMOS_envlibsite-packagestwistedlogger__init__.py", line 105, in <module>
from ._logger import Logger, _loggerFor
File "E:sunil_sachinSSMOS_envlibsite-packagestwistedlogger_logger.py", line 269, in <module>
_log = Logger()
File "E:sunil_sachinSSMOS_envlibsite-packagestwistedlogger_logger.py", line 65, in __init__
from ._global import globalLogPublisher
File "E:sunil_sachinSSMOS_envlibsite-packagestwistedlogger_global.py", line 17, in <module>
from ._buffer import LimitedHistoryLogObserver
File "E:sunil_sachinSSMOS_envlibsite-packagestwistedlogger_buffer.py", line 10, in <module>
from typing import Deque, Optional
ImportError: cannot import name 'Deque'

版本:

Django            3.2.8
channels          3.0.0
channels_redis    3.2
Python            3.6.0

我知道typing模块没有Deque在里面按照

import typing
dir(typing)

输出
['AbstractSet', 'Any', 'AnyStr', 'AsyncIterable', 'AsyncIterator', 'Awaitable', 'BinaryIO', 'ByteString', 'CT_co', 'Callable', 'CallableMeta', 'ClassVar', 'Collection', 'Container', 'ContextManager', 'Coroutine', 'DefaultDict', 'Dict', 'FrozenSet', 'Generator', 'Generic', 'GenericMeta', 'Hashable', 'IO', 'ItemsView', 'Iterable', 'Iterator', 'KT', 'KeysView', 'List', 'Mapping', 'MappingView', 'Match', 'MutableMapping', 'MutableSequence', 'MutableSet', 'NamedTuple', 'NamedTupleMeta', 'NewType', 'Optional', 'Pattern', 'Reversible', 'Sequence', 'Set', 'Sized', 'SupportsAbs', 'SupportsBytes', 'SupportsComplex', 'SupportsFloat', 'SupportsInt', 'SupportsRound', 'T', 'TYPE_CHECKING', 'T_co', 'T_contra', 'Text', 'TextIO', 'Tuple', 'TupleMeta', 'Type', 'TypeVar', 'TypingMeta', 'Union', 'VT', 'VT_co', 'V_co', 'ValuesView', '_Any', '_ClassVar', '_FinalTypingBase', '_ForwardRef', '_G_base', '_Optional', '_PY36', '_Protocol', '_ProtocolMeta', '_TypeAlias', '_TypingBase', '_TypingEllipsis', '_TypingEmpty', '_Union', '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_check_generic', '_cleanups', '_eval_type', '_generic_new', '_geqv', '_get_defaults', '_get_type_vars', '_gorg', '_make_nmtuple', '_make_subclasshook', '_next_in_mro', '_no_slots_copy', '_overload_dummy', '_qualname', '_remove_dups_flatten', '_replace_arg', '_subs_tree', '_tp_cache', '_trim_name', '_type_check', '_type_repr', '_type_vars', '_valid_for_check', 'abc', 'abstractmethod', 'abstractproperty', 'cast', 'collections', 'collections_abc', 'contextlib', 'functools', 'get_type_hints', 'io', 'no_type_check', 'no_type_check_decorator', 'overload', 're', 'stdlib_re', 'sys', 'types']

任何帮助我们的指导将是伟大的提前感谢

Deque类被添加到Python 3.6.1的typing模块中。因此,django-channels项目必须硬依赖于Python 3.6.1+,而不能在Python 3.6.0上运行。

请注意,关于输入模块的文档说它是在3.5.4和3.6.1中添加的,这可能有点令人困惑。这意味着它被添加到3.5和3.6之上的补丁版本中。在3.5.3和3.6.0中都不存在

相关内容

最新更新