2

I am trying to read the contents (blog) from a text file using Python (SpaCy/Textacy/Textblob) but it has been in vain, so far. Following is the code that I have recently tried:

import content as content
import pattern as pattern
import textacy
import spacy
nlp = spacy.load('en')
verb_clause_pattern = r'<VERB><ADV><PART><VERB>+<PART>'
doc = textacy.Doc.content, lang = 'en'
lists = textacy.extract.pos_regex_matches(doc, pattern)
for list in lists:
    print(list.text)

And I am getting following error:

    "E:\TWP\TWP\venv\Scripts\python.exe E:/TWP/TWP/VerbPhrases.py
    Traceback (most recent call last):
      File "E:/TWP/TWP/VerbPhrases.py", line 5, in <module>
        nlp = spacy.load('en')
      File "E:\TWP\TWP\venv\lib\site-packages\spacy\__init__.py", line 30, in load
        return util.load_model(name, **overrides)
      File "E:\TWP\TWP\venv\lib\site-packages\spacy\util.py", line 169, in load_model
        raise IOError(Errors.E050.format(name=name))
    OSError: [E050] Can't find model 'en'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory."
APhillips
  • 1,175
  • 9
  • 17
  • 1
    From https://spacy.io/usage/models, try downloading the en_core_web_sm (python -m spacy download en_core_web_sm), then use nlp = spacy.load("en_core_web_sm"). – APhillips Dec 11 '19 at 17:51
  • @APhillips I did that as well. I have all the libraries and dependencies updated. – user3438153 Dec 13 '19 at 08:40
  • And when I add the line you stated above, it returns with this error: raise IOError(Errors.E050.format(name=name)) 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. – user3438153 Dec 13 '19 at 08:49

1 Answers1

0

This is most probably a linking error caused by spaCy. I keep getting this error. I managed to fix it by running this in Anaconda terminal for example:

python -m spacy download en

Make sure you open the Anaconda terminal as an Administrator for the linking to work on Windows.

If you are using Ubuntu Linux, try this:

sudo python -m spacy.en.download all

In the latest release of spaCy, you can now choose between importing or linking. You may refer to this github issue for more details:

MZe
  • 148
  • 2
  • 5