Module 'collections' has no attribute 'Hashable' error

260 views Asked by At

I ran one of my chatbot codes, but it said there was an error:

File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/yaml/constructor.py", line 126, in construct_mapping if not isinstance(key, collections.Hashable): ^^^^^^^^^^^^^^^^^^^^ AttributeError: module 'collections' has no attribute 'Hashable'

I'm not sure what this means can someone help me come up with a solution?

this is my code: from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer

chatbot = ChatBot('MyBot')

trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train('chatterbot.corpus.english')

def get_response(user_input): response = chatbot.get_response(user_input) return str(response)

print("Hello! I'm your chatbot. Type 'exit' to end the conversation.") while True: user_input = input("You: ")

if user_input.lower() == 'exit':
    print("Bot: Goodbye!")
    break

response = get_response(user_input)
print("Bot:", response)
0

There are 0 answers