chatterbot 出现 OSError: [E941] Can't find model 'en'.错误
Traceback (most recent call last):
File "c:/Myfiles/files/chatterbot/chatter.py", line 3, in <module>
chatbot = ChatBot("hello bot")
File "c:\Myfiles\files\chatterbot\chatterbot\chatterbot.py", line 28, in __init__
self.storage = utils.initialize_class(storage_adapter, **kwargs)
File "c:\Myfiles\files\chatterbot\chatterbot\utils.py", line 33, in initialize_class
return Class(*args, **kwargs)
File "c:\Myfiles\files\chatterbot\chatterbot\storage\sql_storage.py", line 20, in __init__
super().__init__(**kwargs)
File "c:\Myfiles\files\chatterbot\chatterbot\storage\storage_adapter.py", line 22, in __init__
self.tagger = Tagger(language=kwargs.get(
File "c:\Myfiles\files\chatterbot\chatterbot\tagging.py", line 26, in __init__
self.nlp = spacy.load(self.language.ISO_639_1.lower())
File "C:\Myfiles\software\miniforge3\envs\chatterbot\lib\site-packages\spacy\__init__.py", line 47, in load
return util.load_model(name, disable=disable, exclude=exclude, config=config)
File "C:\Myfiles\software\miniforge3\envs\chatterbot\lib\site-packages\spacy\util.py", line 328, in load_model
raise IOError(Errors.E941.format(name=name, full=OLD_MODEL_SHORTCUTS[name]))
OSError: [E941] Can't find model 'en'. It looks like you're trying to load a model from a shortcut, which is deprecated as of spaCy v3.0. To load the model, use its full name instead:
解决办法:
原因:网上找了几篇解决办法看了看,总结了下:spacyV3.0以后不再支持“en”,支持全名称“en_core_web_sm”引用
1.找到上面错误中的tagging
文件位置,可以按照错误中提示的位置查找,我这里的位置为:c:\Myfiles\files\chatterbot\chatterbot\tagging.py
2.修改内容
原始内容为(大概在26行):
self.nlp = spacy.load(self.language.ISO_639_1.lower())
修改后为:
if self.language.ISO_639_1.lower() == 'en':
self.nlp = spacy.load('en_core_web_sm')
else:
self.nlp = spacy.load(self.language.ISO_639_1.lower())
注意:欢迎转载,转载时请注明来源