25

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?

ASHu2
  • 2,027
  • 15
  • 29
codingInMyBasement
  • 728
  • 1
  • 6
  • 20

7 Answers7

34

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.

Ajay Alex
  • 473
  • 4
  • 7
10

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
Zoe
  • 27,060
  • 21
  • 118
  • 148
ASHu2
  • 2,027
  • 15
  • 29
  • 2
    this was already tried, but what did work for me specifically was downloading the en-model directly and installing with pip. Thanks for the help! pip install User/Downloads/en_core_web_lg-2.1.0.tar.gz – codingInMyBasement Jun 06 '19 at 13:38
  • 1
    Yeah, that was also an option. Nice that your problem solved. But if your direct download did not work then I think then you might have multiple python environments or your path is incorrect... – ASHu2 Jun 06 '19 at 14:26
  • 1
    Another cause might be that you weren't running in administrator mode (if you're on windows) when you were running the download command – Andrew Xia Jun 06 '19 at 14:28
  • I executed the second command successfully, but why I got an error `OSError: [E049] Can't find spaCy data directory: 'None'. Check your installation and permissions, or use spacy.util.set_data_path to customise the location if necessary.` when trying to load the `en` model? – wawawa Jul 08 '21 at 19:17
  • did you check this issue : [spacy 3592](https://github.com/explosion/spaCy/issues/3592) – ASHu2 Jul 09 '21 at 17:11
6
import spacy

spacy.cli.download("en_core_web_sm")
nlp = spacy.load("en_core_web_sm")

This works for me! I also searched a lot and found this answer there: How to download additional files from modules on pycharm

joanis
  • 10,635
  • 14
  • 30
  • 40
Jingwen Zhang
  • 61
  • 1
  • 1
1
import en_core_web_sm
nlp = en_core_web_sm.load()

If this works, it'd indicate that the problem is related to the way spaCy detects installed packages. If it doesn't work and gives you an ImportError, it means that the Python environment the model was installed in is not the same as your Jupyter environment.

Also, maybe double-check that the model installed correctly? Models are installed as Python packages by running pip in a subprocess. And pip errors can sometimes be a bit subtle and not immediately obvious in the output.

Chandan Gupta
  • 684
  • 4
  • 11
0

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

0
!python -m spacy download en_core_web_lg 

from your Jupyter cell, then:

[Ctrl+M] or `Restart runtime` 

from menu bar on top of Jupyter notebook

Talha Tayyab
  • 8,111
  • 25
  • 27
  • 44
0

i was getting the same error , Now i am able to solve it by installing "en_core_web_lg" again.Use these steps:

  1. Check Pyhton version using python --version
  2. if your python version is python 2. xx version then install using pip install -U spacy and for python 3. xx version pip3 install -U spacy
  3. install using python -m spacy download en_core_web_lg.Incase it shows the same error , install direcelty using pip3 install https://github.com/explosion/spacy-models/releases/download/de_core_news_lg-3.2.0/de_core_news_lg-3.2.0-py3-none-any.whl.