创建机器人时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

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

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