OSError: [E050] Can't find model 'en_core_web_sm'错误

4月前 ⋅ 226 阅读

chatterbot运行代码chatbot = ChatBot("Ron Obvious")出现 OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a Python package or a valid path to a data directory.错误

  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 28, in __init__
    self.nlp = spacy.load('en_core_web_sm')
  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 329, in load_model
    raise IOError(Errors.E050.format(name=name))
OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a Python package or a valid path to a data directory.

问题原因:
没有下载该模型,因此找不到该模型。
解决办法:
使用如下命令下载该模型:

python -m spacy download en_core_web_sm