chatterbot错误,来自chatterbot.corpus.english



我是python的新手,不想学习更多。用一个简单的聊天机器人让自己变湿。调试程序时出现错误

import time
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
time.clock = time.time

chatbot = ChatBot('Bob') <------ Here (If i didn't use import time module ('time' has no attribute 'clock')error is thrown) 
trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train(
chatterbot.corpus.english'<----- Here i get (Exception has occurred: AttributeError
module 'collections' has no attribute 'Hashable') 
)
bot = ChatBot(
'Bob',
storage_adapter='chatterbot.storage.SQLStorageAdapter',
database_uri='sqlite:///database.sqlite3'
)
bot = ChatBot(
'Bob',  
logic_adapters=[
'chatterbot.logic.BestMatch',
'chatterbot.logic.MathematicalEvaluation',
'chatterbot.logic.TimeLogicAdapter'],
)
response = bot.get_response('Greetings.')
print("Bot Response:", response)
name=input("Enter Your Name: ")
print("Welcome to the Bot Service! Let me know how can I help you?")
while True:
request=input(name+':')
if request=='Bye' or request =='bye':
print('Bot: Bye')
break
else:
response=bot.get_response(request)
print('Bot:',response)
到目前为止,我试图在我的计算机上创建我自己的语料库文件。但不确定它是否会抛出相同的错误,或者这个错误是否与不兼容问题有关。如果你是新手,请帮助我。

感谢

作为一种变通方法,您可以通过添加以下行来强制兼容性:

'time'没有'clock'属性
import time
time.clock = time.time
模块'collections'没有属性'Hashable'
import collections.abc
collections.Hashable = collections.abc.Hashable

应该要求安装与Python 3.10兼容的版本,如下所示:

pip install -U PyYaml==3.12
pip install time

最新更新