Python pip: How to add multiple trusted hosts

PUBLISHED ON MAY 26, 2024 — MACOS, PYTHON, SSL, WINDOWS

I’ve been working with Python lately, and I was facing some issues with ‘pip’ related to an SSL certificate error: SSL CERTIFICATE_VERIFY_FAILED

After spending some time researching and testing, I found a solution: use ‘–trusted-host,’ which is an option to bypass the SSL certificate verification when installing Python packages from the specified host. I’m not saying this is the best option, but if you know what you are doing, then you can try it.

pip config set global.trusted-host "files.pythonhosted.org pypi.org"

This will create a file on your username (if there isn’t one already). To bypass verification, add the URLs files. pythonhosted.org pypi.org to the trusted hosts.

Rest assured, this solution, while not the definitive answer, has proven effective in many cases. It may not be the best approach, but it certainly gets the job done.

REFERENCES:

https://pip.pypa.io/en/stable/topics/configuration/

comments powered by Disqus