安装完spacy后按照网上下载zh_core_web_sm到绝对路径后
使用pip install C:\Users\admin\zh_core_web_sm-3.5.0.tar.gz 后显示成功安装了
Found existing installation: zh-core-web-sm 3.5.0
Uninstalling zh-core-web-sm-3.5.0:
Successfully uninstalled zh-core-web-sm-3.5.0
Successfully installed zh-core-web-sm-3.5.0
但依然报错:
Traceback (most recent call last):
File "F:\C_other\yicun.py", line 14, in <module>
parser = spacy.load('zh_core_web_sm_3.5.0')
File "D:\Python39\lib\site-packages\spacy\__init__.py", line 54, in load
return util.load_model(
File "D:\Python39\lib\site-packages\spacy\util.py", line 449, in load_model
raise IOError(Errors.E050.format(name=name))
OSError: [E050] Can't find model 'zh_core_web_sm_3.5.0'. It doesn't seem to be a Python package or a valid path to a data directory.
这是因为在加载模型时,Spacy无法找到路径。为了解决这个问题,您可以尝试以下方法:
zh_core_web_sm_3.5.0
,但是在安装时使用的是 zh_core_web_sm-3.5.0.tar.gz
。请确认您在加载模型时使用的名称和安装时的名称一致。import zh_core_web_sm
print(zh_core_web_sm.__file__)
这将打印出模型所在的绝对路径。请确认路径是否与您的代码中使用的路径一致。pip uninstall zh-core-web-sm
然后重新下载模型并安装:pip install zh_core_web_sm-3.5.0.tar.gz
希望这些方法能够帮助您解决问题!