ravecoder
ravecoder

Reputation: 201

unable to pip install spacy [model] due to proxy issue

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)

Upvotes: 9

Views: 9828

Answers (4)

JesseZ
JesseZ

Reputation: 91

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

Upvotes: 2

Mahendra S. Chouhan
Mahendra S. Chouhan

Reputation: 545

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

Upvotes: 13

Chandan Gupta
Chandan Gupta

Reputation: 722

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?

Upvotes: 2

Preetham
Preetham

Reputation: 577

Try using

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

or Use this link PIP_Proxy_StackOverflow

Upvotes: 1

Related Questions