在 python 3.x 中使用聊天机器人时出现错误

Sid*_*tam 5 python chatbot chatterbot

这是我的代码:

from chatterbot.trainers import ListTrainer
from chatterbot import chatbot
bot = chatbot('Dona')
conv = open('sample.txt', 'r').readlines()
bot.set_trainer(ListTrainer)
bot.train(conv)
while True:
    query = input("You: ")
    reply = bot.get_response(query)
    print("Bot: ", response)
Run Code Online (Sandbox Code Playgroud)

我收到此错误,我认为无法导入程序

enter code here

from pytz import UTC
ModuleNotFoundError: No module named 'pytz'
Run Code Online (Sandbox Code Playgroud)

这是最后一行错误。

cul*_*zie 4

将pytz安装到您的 python 环境中:

pip install pytz
Run Code Online (Sandbox Code Playgroud)