10

I'm running OS X El Capitan on Python 3.5.2 via Anaconda and have spaCy 0.101.0.

I'm trying to install the spaCy English language model using python -m spacy.en.download. However when I do that, I get an error that says urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)>. The complete Traceback is as follows:

Traceback (most recent call last):
  File "/Users/bsherman/anaconda/lib/python3.5/urllib/request.py", line 1254, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/Users/bsherman/anaconda/lib/python3.5/http/client.py", line 1106, in request
    self._send_request(method, url, body, headers)
  File "/Users/bsherman/anaconda/lib/python3.5/http/client.py", line 1151, in _send_request
    self.endheaders(body)
  File "/Users/bsherman/anaconda/lib/python3.5/http/client.py", line 1102, in endheaders
    self._send_output(message_body)
  File "/Users/bsherman/anaconda/lib/python3.5/http/client.py", line 934, in _send_output
    self.send(msg)
  File "/Users/bsherman/anaconda/lib/python3.5/http/client.py", line 877, in send
    self.connect()
  File "/Users/bsherman/anaconda/lib/python3.5/http/client.py", line 1260, in connect
    server_hostname=server_hostname)
  File "/Users/bsherman/anaconda/lib/python3.5/ssl.py", line 377, in wrap_socket
    _context=self)
  File "/Users/bsherman/anaconda/lib/python3.5/ssl.py", line 752, in __init__
    self.do_handshake()
  File "/Users/bsherman/anaconda/lib/python3.5/ssl.py", line 988, in do_handshake
    self._sslobj.do_handshake()
  File "/Users/bsherman/anaconda/lib/python3.5/ssl.py", line 633, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/bsherman/anaconda/lib/python3.5/runpy.py", line 184, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/bsherman/anaconda/lib/python3.5/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/bsherman/anaconda/lib/python3.5/site-packages/spacy/en/download.py", line 13, in <module>
    plac.call(main)
  File "/Users/bsherman/anaconda/lib/python3.5/site-packages/plac_core.py", line 328, in call
    cmd, result = parser.consume(arglist)
  File "/Users/bsherman/anaconda/lib/python3.5/site-packages/plac_core.py", line 207, in consume
    return cmd, self.func(*(args + varargs + extraopts), **kwargs)
  File "/Users/bsherman/anaconda/lib/python3.5/site-packages/spacy/en/download.py", line 9, in main
    download('en', force)
  File "/Users/bsherman/anaconda/lib/python3.5/site-packages/spacy/download.py", line 24, in download
    package = sputnik.install(about.__title__, about.__version__, about.__models__[lang])
  File "/Users/bsherman/anaconda/lib/python3.5/site-packages/sputnik/__init__.py", line 37, in install
    index.update()
  File "/Users/bsherman/anaconda/lib/python3.5/site-packages/sputnik/index.py", line 84, in update
    index = json.load(session.open(request, 'utf8'))
  File "/Users/bsherman/anaconda/lib/python3.5/site-packages/sputnik/session.py", line 43, in open
    r = self.opener.open(request)
  File "/Users/bsherman/anaconda/lib/python3.5/urllib/request.py", line 466, in open
    response = self._open(req, data)
  File "/Users/bsherman/anaconda/lib/python3.5/urllib/request.py", line 484, in _open
    '_open', req)
  File "/Users/bsherman/anaconda/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/Users/bsherman/anaconda/lib/python3.5/urllib/request.py", line 1297, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/Users/bsherman/anaconda/lib/python3.5/urllib/request.py", line 1256, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)>
Brandon Sherman
  • 673
  • 1
  • 8
  • 25
  • Are you in a corporate environment that uses SSL stripping or a Web proxy by any chance? – Cory Shay Aug 08 '16 at 18:16
  • Is there an easy way to check? – Brandon Sherman Aug 08 '16 at 18:23
  • This usually depends on the vendor being used, but you may be able to see the proxy set up within System Preferences => Network => Connected network => Advanced Settings => Proxies. If any of the options are checked and filled in. Your environment has a proxy and may have a certificate installed to strip SSL. Otherwise you can go to a site such as google and check the certificate information by clicking on the lock => details => view certificate. For Google I have Geotrust, yours may differ depending on if SSL stripping is set up. – Cory Shay Aug 08 '16 at 18:33
  • I definitely don't see a proxy. I'm in a corporate environment but I have root access on my own computer and set it up from scratch. – Brandon Sherman Aug 08 '16 at 18:35
  • Do you get a certificate issue in a browser when you go to: https://index.spacy.io/models/en-1.1.0/archive.gz – Cory Shay Aug 08 '16 at 18:50
  • If you are able to download the `archive.gz` you should be able to place it within the `site-packages/spacy/data/__caches__/en-1.1.0/` On my machine: `/usr/local/lib/python3.5/site-packages/spacy/` and run `python -m spacy.en.download` and it will extract the models. – Cory Shay Aug 08 '16 at 19:09
  • It downloaded for a bit and then I got "Failed - Forbidden" as an error in Chrome. – Brandon Sherman Aug 08 '16 at 19:37
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/120457/discussion-between-cory-shay-and-brandon-sherman). – Cory Shay Aug 08 '16 at 19:41
  • I get a certificate error when clicking that site in the browser so it looks like a server-side problem. Voting to close as not a programming problem. – tripleee Aug 25 '16 at 08:50
  • Same issue over here. Can access index.spacy.io/models/en-1.1.0/archive.gz in browser without issues. – kev Aug 26 '16 at 00:37
  • I faced the same error, but on Ubuntu - solved it by ensuring the machine I was working on had the correct time and date – user799188 Aug 31 '16 at 02:58
  • I can download the [index.spacy.io/models/en-1.1.0/archive.gz], and place the file under the .../-packages/spacy/data/__caches__/en-1.1.0/ folder. However when I ran `python -m spacy.en.download`, it still went to the site and not extracting the model. Any suggestion? – Richard Liu Nov 24 '16 at 19:51

2 Answers2

15

Run in terminal:

/Applications/Python 3.5.2/Install Certificates.command

or update certifi package via pip

Max L
  • 1,453
  • 2
  • 17
  • 32
0

I've come cross this issue several times before and pip install pip-system-certs did the trick for me.

https://pypi.org/project/pip-system-certs/

Ian Thompson
  • 2,914
  • 2
  • 18
  • 31