The most common issue in installing python package in a company's network is failure of verification of SSL Certificate. Sometimes company blocks some websites in their network so employees can't access these websites. Whenever they try to visit these websites, it shows "Access Denied because of company's policy". It causes connection error in reaching main python website.

Error looks like this :

Could not fetch URL https://pypi.python.org/: connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)

PIP SSL Certification Issue

Solution :

Run the following command. Make sure to specify package name in <package_name>
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package_name> -vvv
Suppose you want to install pandas package, you should submit the following line of command
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pandas -vvv

The --trusted-host option mark the host as trusted, even though it does not have valid or any HTTPS
Related Posts
About Author:

Deepanshu founded ListenData with a simple objective - Make analytics easy to understand and follow. He has over 10 years of experience in data science. During his tenure, he has worked with global clients in various domains like Banking, Insurance, Private Equity, Telecom and Human Resource.

1 Response to "PIP connection Error : SSL CERTIFICATE VERIFY FAILED"
  1. In my case, the root caused turned out to be an incorrect system date, which happened to be out of the certificate validity date range at the time of executing pip. This is related to the SSL library and not pip itself. Thus a simple wget or curl call to the offending URL will duplicate the issue.

    Of course, I was also able to work around the issue quickly with --no-check--certificate (or equivalent) for wget and pip.

    This might be a common case with working with SBC like RasberryPi/BeagleBone or any other system where a real-time clock (RTC) is not present out of the box. So lesson learned: Use NTP for to keep system time up-to-date whenever possible.


Next → ← Prev
Love this Post? Spread the Word!