close

[Solved] ImportError: No module named ‘spacy.en’

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error ImportError: No module named ‘spacy.en’ in python. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How ImportError: No module named ‘spacy.en’ Error Occurs?

Today I get the following error ImportError: No module named ‘spacy.en’ in python.

How To Solve ImportError: No module named ‘spacy.en’ Error ?

  1. How To Solve ImportError: No module named 'spacy.en' Error ?

    To Solve ImportError: No module named 'spacy.en' Error The version of spaCy you downloaded from pip is v2.0, which includes a lot of new features, but also a few changes to the API.

  2. ImportError: No module named 'spacy.en'

    To Solve ImportError: No module named 'spacy.en' Error The version of spaCy you downloaded from pip is v2.0, which includes a lot of new features, but also a few changes to the API.

Solution 1

Yes, I can confirm that your solution is correct. The version of spaCy you downloaded from pip is v2.0, which includes a lot of new features, but also a few changes to the API. One of them is that all language data has been moved to a submodule spacy.lang to keep thing cleaner and better organised. So instead of using spacy.en, you now import from spacy.lang.en.

- from spacy.en import English
+ from spacy.lang.en import English

However, it’s also worth mentioning that what you download when you run spacy download en is not the same as spacy.lang.en. The language data shipped with spaCy includes the static data like tokenization rules, stop words or lemmatization tables. The en package that you can download is a shortcut for the statistical model en_core_web_sm. It includes the language data, as well as binary weight to enable spaCy to make predictions for part-of-speech tags, dependencies and named entities.

Instead of just downloading en, I’d actually recommend using the full model name, which makes it much more obvious what’s going on:

python -m spacy download en_core_web_sm
nlp = spacy.load("en_core_web_sm")

When you call spacy.load, spaCy does the following:

  1. Find the installed model named "en_core_web_sm" (a package or shortcut link).
  2. Read its meta.json and check which language it’s using (in this case, spacy.lang.en), and how its processing pipeline should look (in this case, taggerparser and ner).
  3. Initialise the language class and add the pipeline to it.
  4. Load in the binary weights from the model data so pipeline components (like the tagger, parser or entity recognizer) can make predictions.

Solution 2

I used the following command for installing spacy from anaconda distribution.

conda install -c conda-forge spacy

and after that, I was able to download English using the following command without any error.

 python -m spacy download en

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read