Python 无法导入函数

Python can't import function

我有问题。我已经安装了 Rasa 和所有必需的包。但是当我尝试 运行 我的代码时,它给出了这个错误:

from rasa_core.channels.console import ConsoleInputChannel
ImportError: cannot import name 'ConsoleInputChannel' from 'rasa_core.channels.console' (/usr/local/lib/python3.7/dist-packages/rasa_core/channels/console.py)

我做错了什么?

看起来你的代码是为旧版本的 Rasa 编写的,而不是你用来 运行 它的版本。根据迁移指南,ConsoleInputChannel 已被删除。 https://github.com/RasaHQ/rasa/blob/master/docs/core/old-core-migration-guide.rst#changes-to-input-and-output-channels 的文档说:

ConsoleOutputChannel and ConsoleInputChannel have been removed. Either use the run script to run your bot on the cmdline, or adapt the serve_application function to run from a python script.

您可以尝试安装一个旧版本,如果您知道它需要哪个版本,或者您可以调整您的程序以与当前版本的 Rasa 一起工作。