In one of my previous pip posts I wrote about how to Resolve pip install package_name error: Couldn’t find a version that satisfies the requirement, and today we are going to fix another common pip issue.
Getting page https://pypi.python.org/simple/<package_name>/
Could not fetch URL https://pypi.python.org/simple/<package_name>/: connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)
Will skip URL https://pypi.python.org/simple/<package_name>/ when looking for download links for <package_name>
Getting page https://pypi.python.org/simple/
Could not fetch URL https://pypi.python.org/simple/: connection error: HTTPSConnectionPool(host='pypi.python.org', port=443): Max retries exceeded with url: /simple/ (Caused by <class 'http.client.CannotSendRequest'>: Request-sent)
Will skip URL https://pypi.python.org/simple/ when looking for download links for linkchecker
Cannot fetch index base URL https://pypi.python.org/simple/
Prerequisites
- Python
- pip
Cause
The cause is pretty straightforward. You might be sitting behind a firewall and/or proxy, hence your host machine doesn’t trust the Python certificates.
Possible solutions
Solution 1 (Temp). Add the --trusted-host
flag when running pip install. For instance:
pip install <package_name> --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org
Solution 2 (Permanent). Add the Python servers into the pip.conf file.
[global]
trusted-host = pypi.org
pypi.python.org
files.pythonhosted.org
pip.conf file location:
Linux
: $HOME/.config/pip/pip.conf or /etc/pip.conf (Global)macOS
: $HOME/Library/Application Support/pip/pip.confWindows
: %APPDATA%\pip\pip.ini
Conclusion
If you can think of any other alternative solution, please do let me know in the comment section below. On a side note, follow our official channel on Telegram.