找不到模型“en_core_web_md”。它似乎不是快捷方式链接、Python 包或数据目录的有效路径

Raj*_*ora 11 python text nlp python-3.x spacy

我已经安装了 spacy 并下载了 en_core_web_sm : pip install spacy python -m spacy download en_core_web_sm 还尝试了 pip3 install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2。 0.tar.gz

我的spaCy版本:2.2.0 我的Python版本:3.7.4

但是,它仍然显示错误: OSError:[E050]找不到模型'en_core_web_md'。它似乎不是快捷方式链接、Python 包或数据目录的有效路径。

*import aqgFunction
import spacy
import en_core_web_sm
nlp = en_core_web_sm.load()
# Main Function
def main():
    # Create AQG object
    aqg = aqgFunction.AutomaticQuestionGenerator()
    inputTextPath = "E:\Automatic-Question-Generator-master\Automatic-Question-Generator-master\AutomaticQuestionGenerator\DB\db.txt"
    readFile = open(inputTextPath, 'r+', encoding="utf8")
    #readFile = open(inputTextPath, 'r+', encoding="utf8", errors = 'ignore')
    inputText = readFile.read()
    #inputText = '''I am Dipta. I love codding. I build my carrier with this.'''
    questionList = aqg.aqgParse(inputText)
    aqg.display(questionList)
    #aqg.DisNormal(questionList)
    return 0
# Call Main Function
if __name__ == "__main__":
    main()*
Run Code Online (Sandbox Code Playgroud)

Pal*_*ine 15

在 Jupyter 笔记本中使用:

!python -m spacy download en_core_web_md 
Run Code Online (Sandbox Code Playgroud)

然后:

[Ctrl+M] or `Restart runtime` from menu bar
Run Code Online (Sandbox Code Playgroud)

  • 也与 Google Colab 上的 Jupiter Notebook 相关 (2认同)

小智 4

尝试使用它来安装 spacy 和模型:

pip3 install spacy
python3 -m spacy download en_core_web_sm
Run Code Online (Sandbox Code Playgroud)

然后在 python 控制台中运行它们。

nlp = spacy.load("en_core_web_sm")
doc = nlp("Text here")
Run Code Online (Sandbox Code Playgroud)