0
点赞
收藏
分享

微信扫一扫

成功解决OSError: [E050] Can’t find model ‘en_core_web_sm’.

成功解决OSError: [E050] Can't find model 'en_core_web_sm'.

问题描述

在安装spacy包之后,再加载'en_core_web_sm'语言模型时,报出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的错误。

在这里插入图片描述

问题定位

估计是没有安装'en_core_web_sm'这个文件库导致的。

解决方法

尝试:

conda install -c conda-forge spacy-model-en_core_web_sm

这个命令的意思是使用conda包管理工具,从conda-forge这个软件源(channel)中安装英语自然语言处理工具库spacy的en_core_web_sm模型。

但是安装之后,会出现如下警告。

/home/lihuanyu/.conda/envs/show_attend_tell/lib/python3.6/site-packages/spacy/util.py:887: UserWarning: [W095] Model 'en_core_web_sm' (3.1.0) was trained with spaCy v3.1 and may not be 100% compatible with the current version (3.5.2). If you see errors or degraded performance, download a newer compatible model or retrain your custom model with the current spaCy version. For more details and available updates, run: python -m spacy validate

在这里插入图片描述

这是因为版本不兼容导致的。

我们又重现安装了sapcy==3.1这个版本。

pip install spacy==3.1

再重新测试,可以正常加载。

在这里插入图片描述

参考

OSError: [E050] Can't find model 'en_core_web_sm'. 报错解决 - 知乎 (zhihu.com)

举报

相关推荐

0 条评论