Solving ImportError: No module named ‘spacy.en’ in python

ImportError: No module named ‘spacy.en’ in python happens when your spacy installation is faulty or when you don’t know how to install english correctly.

This post is my attempt to explain to you why this error occurs and how you can solve it, I will also include multiple solutions that could be considered as alternative fixes to the error.

Exploring the Error : ImportError: No module named ‘spacy.en’ in python

ImportError: No module named ‘spacy.en’ in python happens when your spacy installation is faulty or when you don’t know how to install english correctly.

The error should look like this. Double check in order to avoid mixing between errors.

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

Bellow are the solutions which worked for me and will help you to successfully solve your problem.

Solution 1 : use spacy.lang.en instead of spacy.en

The first solution is to import from spacy.lang.en instead of spacy.en just like in the code bellow.

                                                                       #
from spacy.lang.en import English
                                                                       #

This is very important. You should first download spacy.lang.en using the command bellow

                                                                       #
python -m spacy download en_core_web_sm
                                                                       #

Finally use this command

                                                                       #
nlp = spacy.load("en_core_web_sm")
                                                                       #

This solution should do the trick, but If this solution does not fix your problem you can try the solution bellow.

Solution 2 : install spacy using conda

This solution is for anaconda users , or for users who are willing to install anaconda in order to get rid of this issue.

The first step is to install spacy using anaconda. You can do that using the command bellow.

                                                                       #
conda install -c conda-forge spacy
                                                                       #

Then use the command bellow in order to download English

                                                                       #
python -m spacy download en
                                                                       #

The solution should be enough, please try the final solution if this fails.

If this article has been useful for your particular case, consider donating to our Kofi account, there is a red button at the top of this page.

Summing-up

The article is over, I hope I have been able to help you solve this error or at least guide you in the right direction, check out other solutions to different errors you can do that by using the search bar on top of this page.

Keep learning, keep coding guys, cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/