Problem with spacy.load(“en_core_web_md”) in Python.

huangapple go评论60阅读模式
英文:

Problem with spacy.load("en_core_web_md") in python

问题

I'm here to provide translations, so I'll only translate the non-code parts of your message. Here's the translation:

"我在使用spaCy库安装en_core_web_md包时遇到了困难。在执行以下代码后:

spacy.load("en_core_web_md")

我遇到了这个错误:OSError: [E050] 找不到模型 'en_core_web_md'。它似乎不是Python包,也不是有效的数据目录路径。

我在终端中使用了以下命令:

python -m spacy download en_core_web_md

终端返回了以下输出:

Problem with spacy.load(“en_core_web_md”) in Python.

我还尝试了手动安装,使用.wheel文件和以下命令:

Problem with spacy.load(“en_core_web_md”) in Python.

但是,即使在执行以下代码后:

print(spacy.util.get_installed_models())

我收到了空括号 [],所以当我执行我的代码时也就不奇怪了:

import pandas as pd
import spacy

def lemmatize_text(text):
    nlp = spacy.load("en_core_web_md")
    doc = nlp(text)
    return " ".join([token.lemma_ for token in doc])

if __name__ == '__main__':
    print(spacy.util.get_installed_models())
    database = pd.read_csv('database.csv')
    database['Lyric'] = database['Lyric'].apply(lemmatize_text)
    database.to_csv('database.csv', index=False)

我在控制台中收到了以下输出:

Problem with spacy.load(“en_core_web_md”) in Python.

OSError: [E050] 找不到模型 'en_core_web_md'。它似乎不是Python包,也不是有效的数据目录路径。

我的安装出了什么问题?我使用的是PyCharm 2023.1,Python 3.11.3和Windows 11。"

英文:

I'm struggling with installation of package en_core_web_md from spaCy library. After executing

spacy.load("en_core_web_md")

I get this error: OSError: [E050] Can't find model 'en_core_web_md'. It doesn't seem to be a Python package or a valid path to a data directory.

I used this command in the terminal:

python -m spacy download en_core_web_md

And terminal returned this output:

Problem with spacy.load(“en_core_web_md”) in Python.

I installed it manually as well, using .whl file and this command:

Problem with spacy.load(“en_core_web_md”) in Python.

Still after executing this line of code:

print(spacy.util.get_installed_models())

I recive empty brackets [], so no wonder when I execute my code:

import pandas as pd
import spacy


def lemmatize_text(text):
    nlp = spacy.load("en_core_web_md")
    doc = nlp(text)
    return " ".join([token.lemma_ for token in doc])


if __name__ == '__main__':
    print(spacy.util.get_installed_models())

    database = pd.read_csv('database.csv')

    database['Lyric'] = database['Lyric'].apply(lemmatize_text)

    database.to_csv('database.csv', index=False)

I get this output in console

Problem with spacy.load(“en_core_web_md”) in Python.

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

What is wrong with my installation? I'm using PyCharm 2023.1, Python 3.11.3 and Windows 11.

答案1

得分: 1

一旦您下载了 en_core_web_md,您需要从菜单栏中选择 重新启动运行时 或按 Ctrl+M

英文:

Once you download en_core_web_md you need to Restart Runtime or Ctrl+M from the menu bar.

huangapple
  • 本文由 发表于 2023年5月22日 01:46:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76301180.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定