Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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. #4577

Closed
icmpnorequest opened this issue Nov 2, 2019 · 7 comments
Labels
install Installation issues jupyter Issues related to Jupyter notebook environments models Issues related to the statistical models

Comments

@icmpnorequest
Copy link

icmpnorequest commented Nov 2, 2019

I have installed spacy and downloaded en_core_web_sm with:

pip3 install spacy
python3 -m spacy download en_core_web_sm

When running codes on Python3 default IDLE, it runs successfully:

import spacy
spacy.load("en_core_web_sm")

However, when I run above codes in jupyter notebook, it shows error:

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.

I tried several ways in Jupyter notebook like

!python3 -m spacy download en_core_web_sm

but it still shows the error.

OS: MacOS

Could somebody help me fix this issue? Thanks in advance!

@ines ines added install Installation issues jupyter Issues related to Jupyter notebook environments models Issues related to the statistical models usage General spaCy usage more-info-needed This issue needs more information and removed usage General spaCy usage labels Nov 2, 2019
@ines
Copy link
Member

ines commented Nov 2, 2019

Which version of spacy are you running? If you're not using the latest, try upgrading.

One common problem with Jupyter notebooks is that they install packages (including spaCy models, which are also just Python packages) in the same Python session and the installed packages are not automatically refreshed. This makes it difficult to detect whether a package is installed or not. More recent versions of spaCy should include a workaround for this.

Also make sure that the python / python3 you're executing within your notebook actually refers to the same environment you're running your notebook in.

@icmpnorequest
Copy link
Author

@ines

I have tried to update my spaCy with !pip3 install -U spacy and !python3 -m spacy download en_core_web_sm in Jupyter notebook.

My spaCy version: 2.2.2
My Python version: 3.7.2

However, when input spacy.load('en_core_web_sm'), it still shows the error:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-14-ec4f59b9cf67> in <module>
----> 1 spacy.load('en_core_web_sm')

/usr/local/lib/python3.7/site-packages/spacy/__init__.py in load(name, **overrides)
     28     if depr_path not in (True, False, None):
     29         deprecation_warning(Warnings.W001.format(path=depr_path))
---> 30     return util.load_model(name, **overrides)
     31 
     32 

/usr/local/lib/python3.7/site-packages/spacy/util.py in load_model(name, **overrides)
    218     elif hasattr(name, "exists"):  # Path or Path-like to model data
    219         return load_model_from_path(name, **overrides)
--> 220     raise IOError(Errors.E050.format(name=name))
    221 
    222 

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.

@no-response no-response bot removed the more-info-needed This issue needs more information label Nov 5, 2019
@ines
Copy link
Member

ines commented Nov 5, 2019

What happens if you run the following?

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.

@icmpnorequest
Copy link
Author

Finally, solve the issue by following:

pip3 install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz

I'm wondering what's the difference between these two command lines for installing en_core_web_sm ?

python3 -m spacy download en_core_web_sm
pip3 install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.0/en_core_web_sm-2.2.0.tar.gz

Thank you for patience and guidance!

@no-response no-response bot removed the more-info-needed This issue needs more information label Nov 6, 2019
@ines
Copy link
Member

ines commented Nov 6, 2019

Glad it worked!

I'm wondering what's the difference between these two command lines for installing en_core_web_sm ?

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.

(In the future, this will hopefully also be less of an issue, because Python 2 will be less common and python3 and pip3 will become python and pip again.)

@ines ines closed this as completed Nov 6, 2019
@foxnic
Copy link

foxnic commented Nov 11, 2019

import en_core_web_sm
nlp = en_core_web_sm.load()

@ines This fixed it for me. Thanks!

@lock
Copy link

lock bot commented Dec 11, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
install Installation issues jupyter Issues related to Jupyter notebook environments models Issues related to the statistical models
Projects
None yet
Development

No branches or pull requests

3 participants