explosion / spacy-streamlit

๐Ÿ‘‘ spaCy building blocks and visualizers for Streamlit apps
https://share.streamlit.io/ines/spacy-streamlit-demo/master/app.py
MIT License
806 stars 115 forks source link

OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a Python package or a valid path to a data directory. #32

Closed deep-woods closed 2 years ago

deep-woods commented 2 years ago

Hi. ๐Ÿ‘‹ This is my first time ever submitting an issue on Github. I resolved the issue somehow myself but I thought it's important to report and share the possible bug anyway. I'll try my best to follow the github issue submit best practices, I hope I'm doing it correctly.

My code

import spacy nlp = spacy.load('en')

Errors I ran into

Error 1

OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a Python package or a valid path to a data directory.

Error 2

[E053] Could not read config.cfg from c:\users\Pycharmprojects\my_project_foler\venv\lib\site-packages\en_core_web_sm\en_core_web_sm-2.2.0\config.cfg

After Error 1, I tried the following link. https://github.com/explosion/spaCy/issues/4577

Then the first error resolved and pycharm threw the error 2 right after. I tried all the pip install github_links but didn't work. https://github.com/explosion/spaCy/issues/7453

Unsuccessful attempts in order

1) download python3 -m spacy download en_core_web_sm

2) Upgrade pip3 install -U spacy

3) Github link 1 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

4) Github link 2 pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0.tar.gz Failed to build spacy

5) validate python -m spacy validate

6) install pip install --no-cache-dir spacy

What worked

python -m spacy download en

As of spaCy v3.0, shortcuts like 'en' are deprecated. Please use the full
pipeline package name 'en_core_web_sm' instead.
Collecting en-core-web-sm==3.2.0

The terminal automatically downloaded en_core_web_sm and it worked. But this was the first thing I had tried. Is it because I used python3 instead of python in the command...?

Thank you!

polm commented 2 years ago

Thanks for posting this. However, since this isn't about spacy-streamlit in particular, it would be better if you had posted at the spaCy repo (and in Discussions, since that's where installation questions go).

Based on your information here I am not really sure what's going on. For example, you say that spacy download en_core_web_sm failed, but you don't give the error. It seems like something was wrong with your spacy install and the pip install fixed it, but it's hard to be sure. Python environments can be complicated to get working at first, and many things can go wrong.

In any case, glad you got it working at least. I would encourage you to look into how to use virtualenvs, which make managing installed libraries much easier to control than using your system Python.

deep-woods commented 2 years ago

@polm Hi thank you for your kind reply. I misposted in a wrong repo... sorry will make sure to not repeat this next time :P Also I greatly appreciate your advice, I will definitely look into it!