我在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
您需要单独安装python 3.8
来使用ChatterBot。