CondaHTTPError - SSL error while installing NLTK

2019-08-25 09:37发布

问题:

I am trying to install NLTK in my tensorflow environment of Anaconda. I have used the command "conda install nltk" for my windows 7 pc. It gives the following error:

 CondaHTTPError: HTTP 000 CONNECTION FAILED for url
 <https://repo.continuum.io/pkgs/r/win-32/repodata.json.bz2>
 Elapsed: -

 An HTTP error occurred when trying to retrieve this URL.
 HTTP errors are often intermittent, and a simple retry will get you on   your way.

 SSLError(MaxRetryError('HTTPSConnectionPool(host=\'repo.continuum.io\', port=443): Max retries exceeded with url: /pkgs/r/win-32/repodata.json.bz2 (Caused by SSLError(SSLError("bad handshake: Error([(\'SSL routines\', \'ssl3_get_server_certificate\', \'certificate verify failed\')],)",),))',),)

I have an additional certificate in my system. So I added the certificate hash to cert.pem file of anaconda/ssl. It worked for Linux machine, but windows machine still throws error. What can I do to solve this?

回答1:

You can still make use of ssl by exporting the CA Certificate from a browser on the windows machine.

http://docs.bvstools.com/home/ssl-documentation/exporting-certificate-authorities-cas-from-a-website

Save the certificate to a folder that you can access, and then simply set the ssl_verify value in your .condarc file to the location of the cert.

ssl_verify: C:\\conda_config\\certificates\\ca_cert.cer

This will allow you to benefit from ssl protection quite easily.



回答2:

I have found the solution. I have modified the .condarc file and set the ssl_verify attribute False. It looks like this:

 channels:
   - defaults
 ssl_verify: False

Now I can add those packaged without any problem.

An alternate way is to modify the configuration file from command line:

conda config --set ssl_verify False

This will edit the file for you, wherever it might be located.