NoModuleName 'channels',但我已经安装了它。姜戈

Posted

技术标签:

【中文标题】NoModuleName \'channels\',但我已经安装了它。姜戈【英文标题】:NoModuleName 'channels', but I have installed it. DjangoNoModuleName 'channels',但我已经安装了它。姜戈 【发布时间】:2019-01-24 21:17:21 【问题描述】:

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',

    ...

]

另外我创建了路由文件并在settings.py中添加了ASGI_APPLICATION = 'mysite.routing.application'

【问题讨论】:

【参考方案1】:

我可以在您的堆栈跟踪中看到,python 环境被称为:venv_linux,您在另一个名为venv 的环境中执行pip list | grep channels

那是你的问题。

【讨论】:

我已经更改了它以便更好地理解。但正如我所见,这是错误的。我解决了我的问题,我在配置中有错误的 python 解释器。谢谢推荐

以上是关于NoModuleName 'channels',但我已经安装了它。姜戈的主要内容,如果未能解决你的问题,请参考以下文章

NIO核心之Channel通道

netty系列之:channel和channelGroup

什么是 gevent.queue.Channel?

netty系列之:channel和channelGroup

go语言管道(channel)

go语言管道(channel)