创建机器人时ChatterBot抛出错误

我在Python中进行一个ChatterBot项目,在训练过程中遇到了一个错误。错误信息如下:

[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 trainfor 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_corpuscorpus_data = read_corpus(file_path)File "C:\Users\Adam\AppData\Local\Programs\Python\Python312\Lib\site-packages\chatterbot\corpus.py", line 38, in read_corpusreturn yaml.load(data_file)TypeError: load() missing 1 required positional argument: 'Loader'

我使用的是ChatterBot库,运行的代码如下:

from chatterbot import ChatBotfrom chatterbot.trainers import ChatterBotCorpusTrainerimport yamlimport timechatbot = 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: 

我希望我的代码能够成为一个聊天机器人控制台,并且该聊天机器人可以访问公共训练数据库。请问您能帮我吗?


回答:

从您的日志来看,您使用的是python 3.12

文档显示ChatterBot仅支持到python 3.8

enter image description here

您需要单独安装python 3.8来使用ChatterBot。

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

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注