I have downloaded spacy in Anaconda prompt by using conda install -c conda-forge spacy. But when I tried to download en_core_we_sm using python -m spacy download en_core_web_sm I getting SSL: CERTIFICATE_VERIFY_FAILED error.

- 279
- 1
- 2
- 12
-
1Possible duplicate of [pip install fails with "connection error: \[SSL: CERTIFICATE\_VERIFY\_FAILED\] certificate verify failed (\_ssl.c:598)"](https://stackoverflow.com/questions/25981703/pip-install-fails-with-connection-error-ssl-certificate-verify-failed-certi) – Naitik Chandak Apr 18 '19 at 11:37
-
No both have different error codes. Mine is (_ssl.c:1056) while the one in the other question is (_ssl.c:598) – Gokul Apr 22 '19 at 09:36
-
That's just different line numbers -- it's normal for them to change between different versions of the library; it's still the same underlying problem, with the same solutions. – Charles Duffy Aug 28 '22 at 15:32
-
Does this answer your question? [I get CERTIFICATE\_VERIFY\_FAILED when I try to install the spaCy English language model](https://stackoverflow.com/questions/38835270/i-get-certificate-verify-failed-when-i-try-to-install-the-spacy-english-language) – Ian Thompson Jul 26 '23 at 20:34
6 Answers
With HTTPS, trying to download something from a remote host produces an SSL connection error in some cases like if your computer is behind a proxy which does not let you to make SSL connection freely. For those cases, a downloading manager like pip , conda for python or apt-get or yum for Linux provide some options for a user to specify certificate for such connections or to allow untrusted communication with a remote host for such downloads.
However, downloading a model VIA spacy with python -m spacy download
does not provide such options. You cannot add any SSL certificates nor specify trusted host for a download.
Fortunately, there's a workaround solution with two separate steps , downloading and installing. That is, download the model with any other clients which is under control with SSL (browser, curl, wget...) then install the downloaded model with pip install
Find appropriate model you need on https://github.com/explosion/spacy-models/releases and download tar.gz file like,
wget https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.2.5/en_core_web_sm-2.2.5.tar.gz
Then install it like,
python -m pip install ./en_core_web_sm-2.2.5.tar.gz
-
3
-
I got most of the answers nearly after a year of posting this question. By the time I probably skipped this question. And right now I don't recall what I was working on and so can not verify it. If there are many up ticks for the answer then the answer should probably work. Sorry about that! – Gokul May 10 '22 at 03:51
-
The answer provided by K. Symbol is helpful. As an alternative, the download and installation can be done in one statement with pip. Pip can be assigned "trusted-host" and the "install" object can be a website, so:
pip --trusted-host github.com --trusted-host objects.githubusercontent.com install https://github.com/explosion/spacy-models/releases/download/en_core_web_md-3.4.0/en_core_web_md-3.4.0.tar.gz

- 96
- 1
- 6
Just download the direct version.
python -m spacy download en_core_web_sm-2.2.0 --direct
I had the same error as you, gave this a try, and it worked. For more information here are some additional details from the model page: https://spacy.io/usage/models

- 346
- 1
- 10
For me the issue was i was running the command "python -m spacy download en" from a different location other than "C:\WINDOWS\system32". When i ran the command from "C:\WINDOWS\system32" with "Run as Admin" it worked like charm. Seems from other locations it is not able to load the correct ssl config.

- 81
- 1
- 6
If you are unable to download it because you cannot verify the certificate as you are behind a company proxy, you can also do the following by first downloading the file via requests and specifying that you don't want to check certifictates, then install it via pip:
import requests, os
lang = 'en'
r = requests.get(f'https://github.com/explosion/spacy-models/releases/download/{lang}_core_news_sm-3.0.0/{lang}_core_news_sm-3.0.0-py3-none-any.whl',
verify=False) # verify=False to skip checking of certificate
file = f'{lang}_core_news_sm-3.0.0-py3-none-any.whl'
with open(file,'wb') as output_file:
output_file.write(r.content) # save the wheel locally
# then install it via pip
!pip install {file} --user
os.remove(file) # remove the file

- 1,823
- 1
- 8
- 24
First, Uninstall Spacy and clean the directories. Then install with the following link -
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org spacy
Use pip3 for Python3 and run following in a terminal
python -m spacy download en_core_web_sm
let me know if you still get error/s. Follow https://spacy.io/usage/models

- 110
- 1
- 3
- 14
-
1This cannot be a solution as the problem caused by disabled SSL connection while downloading spacy model where a user cannot let the download command to trust any host with or without a specific certificates. Reinstalling with the "trusted-host" option does not affect any following SSL requests made after the installation. Also, the link describes nothing about a solution to this problem. – Lyle Jan 30 '20 at 05:35
-
Basically that solution worked for me, also trusted host is from pypi.org from where the library will get downloaded. – Naitik Chandak May 24 '20 at 06:04
-
@NaitikChandak, if you don't force ssl certificates to be validated, how do you know it's _really_ pypi.org that the download is coming from? Could be some hacker who took over your coffeeshop wifi and is substituting their own code with a bitcoin miner added to the library you want. – Charles Duffy Aug 28 '22 at 15:34