7

I am trying to install a specific Spacy model "en_core_web_sm". I am unable to do this due to proxy server limitations I am having in my env that I have no control over.

I am using the following command as advised in their documentation: https://github.com/explosion/spacy-models

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

I figured the other way is to manually download the zip and copy it to the appropriate directory. I am unable to figure out where to place these files in my Anaconda setup to make it work.

Can someone suggest where I can put these files or propose an alternative?

(I have done set proxy etc etc and it works for plenty of other libraries, even installing Spacy itself but this specific model refuses to install)

ravecoder
  • 181
  • 5
  • 16

4 Answers4

12

You are behind the proxy and are you able to download the model directly from the release in your browser. First Download the tar file.

https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0.0.tar.gz

The .tar.gz archive is the same file that's downloaded during spacy download, and its an installable Python package. So if you have the file, you can also do the following:

pip install /path/to/en_core_web_sm-2.0.0.tar.gz

You should then be able to use the model like this:

import spacy

nlp = spacy.load('en_core_web_sm')

You can also download other spacy model in same way Or you can also use proxy in pip install but it not work in my case.

pip --proxy <proxy> https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz
  • I downloaded the whl file and tried to install it. But it seems network connectivity is still needed. How to solve this? – Charles Aug 17 '21 at 03:40
  • Spacy always want user download models as per the need this is not available in wheel or zip file, so I don't think downloading the wheel will help you. – Mahendra S. Chouhan Aug 21 '21 at 18:43
3

Looks like you're trying to install on a corporate network with a firewall in place, can you connect to another WiFi or hot spot and try downloading again?

Chandan Gupta
  • 684
  • 4
  • 11
2

Not sure if this is still relevant, but this question helped me when I ran into the same issue while using SpaCy 1.8.2 and calling

python -m spacy download en.

Looking through the source, I found that when you download a language model, internally SpaCy is calling pip to install the language model, and then creating a symlink in the python environment's spacy/data directory. The relevant files to look at would be

spaCy-1.8.2\spacy\cli\downdload.py

spaCy-1.8.2\spacy\cli\link.py

My solution was to download the language model locally and add these two lines to my setup script:

pip install "en_core_web_sm-1.2.0.tar.gz"

ln -s "env/lib/python3.5/site-packages/en_core_web_sm/en_core_web_sm-1.2.0" env/lib/python3.5/site-packages/spacy/data/en

JesseZ
  • 91
  • 1
  • 4
1

Try using

pip --proxy http://username:password@proxy-host:proxy-port install package-name

or Use this link PIP_Proxy_StackOverflow

Preetham
  • 577
  • 5
  • 13
  • 2
    Tried and failed. I think the specific endpoint it's hitting is blocked by the env i am working in. Have also tried set HTTP_PROXY, HTTPS_PROXY no luck with that either :( – ravecoder Apr 24 '19 at 14:38