Failed to load spaCy model 'en_core_web_sm'

Viewed 4019

Being complete python novice, I am trying to learn some spaCy basics. Problem is, I can not load any models.

I am using Microsoft Visual Studio Community(MVSC), Windows 7, Python 3.7.5., pip 19.2.3 spaCy has been installed via pip on Python 3.7 (64-bit) environment.

(1) when I run in MVSC:

import spacy

nlp = spacy.load("en_core_web_sm")

I am getting: “OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.”

(2) When I run the same code in IDLE Python 3.7 (64-bit) I am getting the same error as in (1). Within modules list, I can see there is spaCy. Via “help(SPACY)” it lists “PACKAGE CONTENTS”, there is no word like “model”; FILE is “c:\program files (x86)\microsoft visual studio\shared\python37_64\lib\site-packages\spacy_init_.py”

(3) When I run in CMD with Admin privileges python -m spacy download en_core_web_sm I am getting: “No module named spacy”. When listing modules via python>help()>modules; I can see the list of available modules, but there is no module spaCy.

(4) For the other trials in MVSC, I created a new 64bit Python environment, successfully installed spaCy via “install spacy (2.3.2)” => ran the above code, and got the same errors as above.

2 Answers

Have you checked the project's GitHub repo? There is a closed issue that seems to be close (minus the spaCy version you're using)

https://github.com/explosion/spaCy/issues/4577

When you run python -m spacy download en_core_web_sm, it will pretty much execute the same thing (pip install [link]), with pip running in a subprocess. The download also takes care of finding you the right version of the model and outputting helpful messages.

However, if the pip executed with python3 -m pip install isn't the same as pip3 install, it may execute the wrong pip and install the model in a different environment. In most environments, this is not a problem – but if it is, installing the models directly via the link is a fine solution.

this is happening because spacy vocab for English is missing, try to activate the python environment and run : python -m spacy download en this will download English vocabulary.

It worked for me, hope it works for you. :)

Thanks Regards

Related