python - 已安装聊天机器人但在导入 ChatBot 时出现错误

标签 python chatterbot

from chatterbot import ChatBot
from chatterbot.trainers import ListTrainer
import os

bot = ChatBot('Bot')
bot.set_trainer(ListTrainer)

for files in os.listdir('D:/Anaconda3/Lib/site-packages/chatterbot_corpus/data/english'):
    data = open('D:/Anaconda3/Lib/site-packages/chatterbot_corpus/data/english' + files, 'r').readlines()
    bot.train(data)
while True:
    message = input('You')
    if message.strip() != 'Bye':

        reply = bot.get_response(message)
        print('ChatBot :', reply)
    if message.strip() == 'Bye':
        print('ChatBot : Bye')
        break  

我收到一个错误:

Traceback (most recent call last): File "C:\Users\nakulmagotra\Desktop\chatbot_train.py", line 1, in from chatterbot import ChatBot ModuleNotFoundError: No module named 'chatterbot'

我完全是 Chatterbot 的菜鸟。 谢谢。

最佳答案

根据 this , 你应该通过 pip install chatterbot 安装它或者使用 git clone https://github.com/gunthercox/ChatterBot 手动安装它并进入克隆目录运行 python setup.py 安装。之后,您可以使用 import chatterbot 简单地检查它,看看它是否显示错误。

关于python - 已安装聊天机器人但在导入 ChatBot 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54662891/

相关文章:

python - 从列表交互中将数据插入 mysql 表的最佳方法

python - 聊天机器人需要很长时间才能返回响应

json - Chatterbot 和 Django 集成中获取 JSON 的属性值

python - 通过正则表达式分割,不会在 Python 中产生空字符串

python - pydbg 无法导入 pydasm - Python 2.7

javascript - HTML 中动态添加的 (JQuery) 列表行中的链接不可单击

python-3.x - 当包含由wsgi脚本托管的chatter bot的flask应用程序无法打开数据库文件时发生错误(sqlite3.OperationalError)

python - 转置 csv 同时保留 ID

python - 为什么在 snakefile 中设置 `wildcard_constraints` 会阻止删除标记为 `temp` 的文件?