Spacy nlp = spacy.load(“en_core_web_lg”)

℡╲_俬逩灬. 提交于 2021-01-21 03:48:07

问题


I already have spaCy downloaded, but everytime I try the nlp = spacy.load("en_core_web_lg"), command, I get this error:

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

I already tried

>>> import spacy
>>> nlp = spacy.load("en_core_web_sm")

and this does not work like it would on my personal computer.

My question is how do I work around this? What directory specifically do I need to drop the spacy en model into on my computer so that it is found?


回答1:


For a Linux system run the below code in terminal if you would be using a virtual environment else skip first and second command :

python -m venv .env
source .env/bin/activate
pip install -U spacy
python -m spacy download en_core_web_lg

The downloaded language model can be found at :

/usr/local/lib/python3.6/dist-packages/en_core_web_lg -->
/usr/local/lib/python3.6/dist-packages/spacy/data/en_core_web_lg

For more documentation information refer https://spacy.io/usage

Hope it was helpful.




回答2:


Commands to install any package from spacy check here about en_ore_web_lg ~800MB:

python -m spacy download en

python -m spacy download en_core_web_sm



回答3:


In case pip install en_core_web_sm worked fine for you. You could apply en_core_web_sm.load() and store this into variable which will work similar to the command you are trying to do.

Failure of spacy.load could be due to the path setup for getting the library.

For more details you can read : I have explained custom NER in detail too.

https://medium.com/analytics-vidhya/spacy-knowing-these-secrets-will-make-wonderful-package-look-amazing-e0f53775720e



来源:https://stackoverflow.com/questions/56470403/spacy-nlp-spacy-loaden-core-web-lg

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!