'Could not install packages due to an OSError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1131)
I'been trying to sovle this problem by reading differents answers in here but none of them turn out to be "the solution",so I would try to breafly explain my situation so you guys can give me a clue.
The thing is that when I try to run pip install <package>
it start with this warnings (just to show you, use as an example fastapi):
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1131)'))': /packages/4f/46/226355e82ccb4be82e06269e9a546f16c1d87fbda2286fb5d36a1c31af9e/fastapi-0.75.0-py3-none-any.whl
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1131)'))': /packages/4f/46/226355e82ccb4be82e06269e9a546f16c1d87fbda2286fb5d36a1c31af9e/fastapi-0.75.0-py3-none-any.whl
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1131)'))': /packages/4f/46/226355e82ccb4be82e06269e9a546f16c1d87fbda2286fb5d36a1c31af9e/fastapi-0.75.0-py3-none-any.whl
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1131)'))': /packages/4f/46/226355e82ccb4be82e06269e9a546f16c1d87fbda2286fb5d36a1c31af9e/fastapi-0.75.0-py3-none-any.whl
And it ends with:
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Max retries exceeded with url: /packages/4f/46/226355e82ccb4be82e06269e9a546f16c1d87fbda2286fb5d36a1c31af9e/fastapi-0.75.0-py3-none-any.whl (Caused by SSLError(SSLCertVerificationError(1,'[SSL:CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate(_ssl.c:1131)')))
The first thing that I tried was pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package>
, but it only gave me another error. So I started to read about SSL Certificates, and when the error says self signed certificates it means that the server that I'm trying to connect, his certificte is self-signed by the server itself or the entity that provides the chain signature is not in the white list of the browser.
And in fact it is so!.
But when I use some of the online tools to check the certificates for this site everything seems to be reliable.
Context:
- Last time I download a package was about a month ago (I realize of this yesterday)
- Python version: 3.8.10 / pip version: 21.1.1
- Windows 10 / Personal machine and Home network (No company permissions)
- This happend at every level: when trying to build a docker, inside a
venv
and also at System level (outside venv)
So, I don't know where to start really. Is my local machine the problem?, is pythonhosted the problem?, Am I mixing things up?, Should I uninstall/re-install Python?
Solution 1:[1]
Below command should solve your problem.
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org
<package-name>
Eg:
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org
pandas
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | maximus383 |