Fixing Python Error – SSL: CERTIFICATE_VERIFY_FAILED certificate verify failed (_ssl.c:749) when using pip to install packages

Python Error – SSL: CERTIFICATE_VERIFY_FAILED certificate verify failed (_ssl.c:749) when using pip to install packages is an error which occurs sometimes when the proper SSL certificate is not installed on your system.

In this blog post I attempt to present a clear explanation of why this error takes place and how you to solve it, I am also going to explain other ways to solve the error if possible.

Exploring the Python Error – SSL: CERTIFICATE_VERIFY_FAILED certificate verify failed (_ssl.c:749) when using pip to install packages

This is an error which occurs sometimes when the proper SSL certificate is not installed on your system.

Bellow is the error message, please make sure it is the right one.

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

I hope one of the solutions bellow will help you solve the problem and get rid of the error for good.

Solution 1 : Correctly install the missing SSL certificate

We have established the fact that when the proper SSL certificate is not installed on your system the error we are trying to solve takes place.

The solution is simple, we should install the missing SSL certificate.

Use your package manager to install the certificate. In my case I am using pip

                                                                       #
pip install certifi
                                                                       #

Since the error happens a lot after you try to install some python package, you can go ahead and install the package you were trying to install in the first place.

                                                                       #
pip install <somepackage>
                                                                       #

Generally, the option above is the best one. If you do not care about exposing yourself to security vulnerabilities, you can use the command bellow.

                                                                       #
pip install --trusted-host pypi.python.org autopep8 ( the package you want to install )
                                                                       #

I hope your problem is solved, please try the method bellow if that is not the case.

Solution 2 : install the python package using –trusted-host pypi.python.org and more …

Try this method if the one above did not work.

                                                                       #
pip install --index-url=http://pypi.python.org/simple/ --trusted-host pypi.python.org ( the package you want to install )
                                                                       #

for python3 users try one of the commands bellow

                                                                       #
pip3 install --trusted-host pypi.org --trusted-host files.pythonhosted.org ( the package you want to install )
python3 -m pip install --upgrade ( the package you want to install ) --trusted-host pypi.org --trusted-host files.pythonhosted.org
                                                                       #

I hope the commands above did the trick.

I hope the methods above have fixed your problem. Good luck with your python projects.

Summing-up : 

Here we are at the end of the road, at the end of this article, if you solved this error congrats, this was a confusing error for me the first time I encountered it.

Thank you for reading my blog post to the end, If you want to learn more about the Python programming language, check out the official Python Documentation : https://docs.python.org/3/