pythonpython-3.xpipartificial-intelligencechatterbot

ChatterBot throws error when creating bot


I am working on a ChatterBot project in Python, and I am encountering an error during training. The error message is as follows:

[nltk_data] Downloading package averaged_perceptron_tagger to
[nltk_data] C:\Users\Adam\AppData\Roaming\nltk_data...
[nltk_data] Package averaged_perceptron_tagger is already up-to-
[nltk_data] date!
[nltk_data] Downloading package punkt to
[nltk_data] C:\Users\Adam\AppData\Roaming\nltk_data...
[nltk_data] Package punkt is already up-to-date!
[nltk_data] Downloading package stopwords to
[nltk_data] C:\Users\Adam\AppData\Roaming\nltk_data...
[nltk_data] Package stopwords is already up-to-date!
Traceback (most recent call last):
File "C:\Users\Adam\Downloads\bot].py", line 12, in <module>
trainer.train("chatterbot.corpus.english.greetings",
File "C:\Users\Adam\AppData\Local\Programs\Python\Python312\Lib\site-packages\chatterbot\trainers.py", line 138, in train
for corpus, categories, file_path in load_corpus(*data_file_paths):
File "C:\Users\Adam\AppData\Local\Programs\Python\Python312\Lib\site-packages\chatterbot\corpus.py", line 63, in load_corpus
corpus_data = read_corpus(file_path)
File "C:\Users\Adam\AppData\Local\Programs\Python\Python312\Lib\site-packages\chatterbot\corpus.py", line 38, in read_corpus
return yaml.load(data_file)
TypeError: load() missing 1 required positional argument: 'Loader'

I am using the ChatterBot library, and the code I am running is as follows:

from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
import yaml
import time

chatbot = ChatBot('phil')
trainer = ChatterBotCorpusTrainer(chatbot)

trainer.train("chatterbot.corpus.english.greetings",
              "chatterbot.corpus.english.conversations")

while True:
    try:
        user_input = input("You: ")
        bot_response = chatbot.get_response(user_input)
        print(f"MyChatBot: {bot_response}")
    except (KeyboardInterrupt, EOFError, SystemExit):
        break
````      note: This error originates from a subprocess, and is likely not a problem with pip.
        ERROR: Failed building wheel for srsly
      Failed to build preshed thinc blis srsly
      ERROR: Could not build wheels for preshed, thinc, blis, srsly, which is required to install pyproject.toml-based projects
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
Chatterbot is installed as 1.2.0 as it threw errors when i tried to upgrade: 

I would like my code to be a chatbot console, and the chatbot could access a database from a public training database. Please could you help me


Solution

  • From your logs, it looks like you are using python 3.12

    Document says that chatterbot only support till python 3.8

    enter image description here

    You need to install python 3.8 separately to work on chatterbot.

    https://pypi.org/project/ChatterBot/