chatbot error: [E941] Can‘t find model ‘en‘

今天尝试运行一个chatbot的demo,创建实体时报错:

Traceback (most recent call last):
  File "c:/users/USER/desktop/bot.py", line 77, in <module>
    chatbot = ChatBot('Ron Obvious')
  File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\chatterbot\chatterbot.py", line 28, in __init__
    self.storage = utils.initialize_class(storage_adapter, **kwargs)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\chatterbot\utils.py", line 33, in initialize_class
    return Class(*args, **kwargs)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\chatterbot\storage\sql_storage.py", line 20, in __init__
    super().__init__(**kwargs)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\chatterbot\storage\storage_adapter.py", line 21, in __init__
    'tagger_language', languages.ENG
  File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\chatterbot\tagging.py", line 13, in __init__
    self.nlp = spacy.load(self.language.ISO_639_1.lower())
  File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\site-packages\spacy\__init__.py", line 47, in load
    return util.load_model(name, disable=disable, exclude=exclude, config=config)
  File "C:\Users\USER\AppData\Local\Programs\Python\Python37\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:

nlp = spacy.load("en_core_web_sm")

For more details on the available models, see the models directory: https://spacy.io/models. If you want to create a blank model, use spacy.blank: nlp = spacy.blank("en")

其实个人感觉是包和包之间的冲突,spacyV3.0以后不再支持“en”这样简单的引用,期待全名称“en_core_web_sm”引用。而chatbot则未能跟进,源码中保持尝试“en”这样的deprecated的shortcut。

解决方法:

进入py环境下chatbot包中的tagging.py模块,将报错信息中提到的这句:

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())

重新加载后问题解决。

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值