Reputation:
I'm new to python and have been stuck on one issue: I have to execute a python file in visual studio code, which is giving me an error
ModuleNotFoundError: No module named 'en_core_web_sm'
,
even though I have downloaded en-core-web-sm 2.2.5.
Please, help me to solve this issue Thanks and Regards,
import spacy
import re
import json
import pymongo
import datetime
import sys
import xlrd
import xlsxwriter
import openpyxl
from openpyxl import Workbook
from pathlib import Path
nlp = spacy.load("en_core_web_sm")
Upvotes: 12
Views: 30854
Reputation: 158
I been trying to solve this issue for an hour... tried everything and the simple code block down below solved all my problems 0_0
import spacy
spacy.cli.download("en_core_web_sm")
nlp = spacy.load("en_core_web_sm")
Upvotes: 1
Reputation: 37
for me this code works :
!pip install spacy -q
!python -m spacy download en_core_web_sm -q
and
# Text modules
import spacy
import en_core_web_sm
from spacy.lang.en.stop_words import STOP_WORDS
It's ok for JupyterNotebook and google colab
Upvotes: 1
Reputation: 1
This solution from @amit finally worked for me!
python -m spacy download en_core_web_sm
Afterwards it showed this:
Successfully installed en-core-web-sm-3.3.0
✔ Download and installation successful
You can now load the package via spacy.load('en_core_web_sm')
nlp = spacy.load('en_core_web_sm')
Upvotes: 0
Reputation: 962
I faced the same issue and used the following steps to resolve it:
Go to the command prompt and activate the environment for which you need the "en_core_web_sm"
, using the command:
conda activate <your environment name>
if you are using the base environment then no need for the above steps (provided you've set the environment variables.
python -m spacy download en_core_web_sm
In my case it downloaded
en-core-web-sm==3.2.0
Voila,you are done...
Upvotes: 0
Reputation: 12804
You can install a downloaded python whl
file via the python package manager pip e.g.:
pip install en_core_web_sm-3.1.0-py3-none-any.whl
You can download a en_core_web_sm
from this page:
https://github.com/explosion/spacy-models/releases/tag/en_core_web_sm-3.1.0
The example from the spacy front page looks easy, have you tried the commented first lines in your terminal? Example from spacy page:
# pip install -U spacy
# python -m spacy download en_core_web_sm
import spacy
# Load English tokenizer, tagger, parser and NER
nlp = spacy.load("en_core_web_sm")
Lines to execute in terminal before usage in python:
pip install -U spacy
python -m spacy download en_core_web_sm
Please check also the docs from spacy and how to install and download model packages..
Maybe you need to install the whole spacy package and not only one sub package e.g.:
pip install -U pip setuptools wheel
pip install spacy
A good starting point to learn python is reading some docs ;-) Maybe this can help too:
What Are Python Wheels and Why Should You Care?
A full working example can be found on the spacy docs page for this package too. Note it uses the package version 3.1.0
.
import spacy
from spacy.lang.en.examples import sentences
nlp = spacy.load("en_core_web_sm")
doc = nlp(sentences[0])
print(doc.text)
for token in doc:
print(token.text, token.pos_, token.dep_)
Upvotes: 12
Reputation: 63
I guess you haven't imported the package. Import that and try once
import en_core_web_sm
nlp = en_core_web_sm.load()
If not working still, try re-installing it again as shown below :
pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.5.tar.gz
or
python -m spacy download en_core_web_lg
python -m spacy download en_core_web_sm
along with
python -m spacy download en
Either of these should work.
Upvotes: 2