英文:
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
终端返回了以下输出:
我还尝试了手动安装,使用.wheel文件和以下命令:
但是,即使在执行以下代码后:
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)
我在控制台中收到了以下输出:
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:
I installed it manually as well, using .whl file and this command:
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
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论