Django版本2.1.5 频道版本2.1.6 Ubuntu 18.0.4
当我在pyCharm中运行项目时,它说:
Unhandled exception in thread started by <function check_errors.
<locals>.wrapper at 0x7f18ecd8eb70>
Traceback (most recent call last):
File "/home/mercer/venv_linux/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/mercer/venv_linux/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/mercer/venv_linux/lib/python3.6/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "/home/mercer/venv_linux/lib/python3.6/site-packages/django/core/management/__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "/home/mercer/venv_linux/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/home/mercer/venv_linux/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/mercer/venv_linux/lib/python3.6/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/home/mercer/venv_linux/lib/python3.6/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'channels'
已安装模块
(venv) mercer@mercerPC:~/Documents/comet$ pip list | grep channels
channels 2.1.6
这是已安装的应用程序:
INSTALLED_APPS = [
'channels',
'chat',
'accounts',
'events',
...
]
我还创建了路由文件,并在ASGI_APPLICATION = 'mysite.routing.application'
中添加了settings.py
答案 0 :(得分:3)
我可以在您的堆栈跟踪中看到python环境称为:venv_linux
,您在另一个名为pip list | grep channels
的环境中执行venv
。
那是你的问题。