0

I've pip-installed NLTK, and am trying to download corpora with nltk.download(). The GUI pops up, but then I get this error, as shown below:

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)

enter image description here

There are several questions and answers about this generally, but none of them appear to help if you're running a Python other than the one shipped on python.org. In my case, I'm running a Python 3.6 that I installed through Homebrew, and that inside a virtual environment (using pipenv, if that's relevant). As a result, I do not have any version of Python that comes with the Install Certificates.command script mentioned in other answers.

This code will eventually run in production, so disabling SSL certificate checking is unacceptable.

Now to the question: Given this setup, what is the right way, reproducibly (i.e., on fresh machines) and without ugly hacks, to overcome this SSL error and download NLTK corpora?

  • You *may* need to have your sysadmin administer you a valid cert that you can put into the `REQUESTS_CA_CERT` environment var. In Mac, this should be part of your `bash_profile` – C.Nivs Sep 21 '18 at 18:14
  • Thanks, @C.Nivs I tried this out but it didn't work. Details: https://gist.github.com/anseljh/74b442de518f189dbe4a5fa39940fed2 – Ansel Halliburton Sep 21 '18 at 18:43
  • What is your output of `import sys; print(sys.version_info)`? – alvas Sep 21 '18 at 20:56
  • @alvas: `sys.version_info(major=3, minor=6, micro=5, releaselevel='final', serial=0)` – Ansel Halliburton Sep 21 '18 at 21:25
  • What is the output of `which python` on the terminal? – alvas Sep 23 '18 at 07:56
  • @alvas: `(repo-name-s7XLw6jn) repo-name $ which python` gives `/Users/anseljh/.local/share/virtualenvs/repo-name-s7XLw6jn/bin/python` and `(repo-name-s7XLw6jn) repo-name $ python --version` gives `Python 3.6.5` – Ansel Halliburton Sep 24 '18 at 15:55
  • What is the output of `ls /Users/anseljh/.local/share/virtualenvs/repo-name-s7XLw6jn/bin/` on ther terminal? – alvas Sep 24 '18 at 22:19

0 Answers0