Search code examples
pythonpython-3.xmodelnlpspacy

How can you solve a model installation problem with spaCy?


I successfully installed spaCy (v 2.2.0) for Windows 10. Then I tried to install the english model en_core_web_sm, which resulted in the following error message: SyntaxError: invalid syntax. Other language models doesn't work either. The solution proposed in this thread - How to fix 'invalid syntax' for downloading spacy model - is not correct because I did not use quotation marks. Does anyone have an idea what this could be due to?

Used installation command: pip install spacy Used model installation command: python -m spacy download en_core_web_sm


Solution

  • The syntax error is not on the en_core_web_sm but spacy

    https://spacy.io/usage/models#download-manual

    You need to download the package manually and then unzip to your root folder : https://github.com/explosion/spacy-models/releases/tag/en_core_web_sm-2.2.5

    then in your python file :

    import spacy
    nlp = spacy.load('en_core_web_sm-2.2.5/en_core_web_sm/en_core_web_sm-2.2.5')