spacy安装错误OSError:[E050]找不到模型'en_core_web_sm'。它似乎不是快捷方式链接、Python 包或

问题描述 投票:0回答:1

我正在尝试从 anaconda 提示符安装 spacy。我首先打开 anaconda 提示符并以管理员身份运行它。之后我发出了这些命令。

conda install -c conda-forge spacy
python -m spacy download en
。然后,我转到 VScode 并尝试使用以下代码导入它:

import spacy

nlp = spacy.load('en_core_web_sm')

它给了我以下错误:

OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.

我搜索了这个stackoverflow线程并使用了命令

conda install -c conda-forge spacy
conda install -c conda-forge spacy-model-en_core_web_sm
。我仍然遇到同样的错误。

任何帮助都会有所帮助。谢谢!!!

python nlp spacy
1个回答
0
投票
Check Installation: Make sure that Spacy is installed correctly. You can do this by running the following command in your Anaconda prompt:

conda list | findstr spacy
This will show you the installed Spacy version

Check Model Installation: Ensure that the 'en_core_web_sm' model is installed. You can do this by running:
python -m spacy validate
This will check for installed models and their compatibility.

Reinstall the Model: If the model is missing or corrupted, you can reinstall it using the following command:

python -m spacy download en_core_web_sm
Specify Full Path: Instead of relying on the default model loading mechanism, you can specify the full path to the model directory. You can find the model directory by running the following command in your Python environment:

import spacy
print(spacy.__file__)
Then, use the path to the 'en_core_web_sm' model in your code:

import spacy
nlp = spacy.load('/path/to/your/spacy/models/en_core_web_sm')
Ensure that your Python environment has the necessary permissions to access the model directory.
© www.soinside.com 2019 - 2024. All rights reserved.