Skip to content

How to Fix 'pip install' SSL Certificate Error

DodaTech 2 min read

In this tutorial, you'll learn about How to Fix 'pip install' SSL Certificate Error. We cover key concepts, practical examples, and best practices.

The Problem

You run pip install and get:

pip install requests
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)'))': /simple/requests/

pip cannot verify the SSL certificate of the PyPI server. The download fails, and no package gets installed.

Quick Fix

1. Upgrade certifi (most common fix)

The certifi package bundles root certificates that pip trusts. If they are outdated:

pip install --upgrade certifi

If you cannot install anything at all, use your system certificates:

# On Linux (Debian/Ubuntu)
sudo apt install ca-certificates

# On macOS
brew install ca-certificates

# Find the system certificate bundle
python3 -c "import ssl; print(ssl.get_default_verify_paths())"

2. Use --trusted-host as a temporary bypass

If you need to install something urgently:

pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org requests

This disables certificate verification for those hosts. Use it only to install or upgrade certifi, then revert to normal operation.

3. Upgrade Python

Python 3.6 and earlier have outdated SSL modules. Check your version:

python3 --version

If you are below Python 3.8, upgrade:

# Ubuntu/Debian
sudo apt update
sudo apt install python3.10 python3.10-venv python3.10-dev

# macOS
brew install python@3.10

Older Python versions lack modern root certificates and may not support newer TLS protocols.

4. Configure proxy settings

Corporate networks with HTTPS intercepting proxies cause certificate errors:

# Set proxy environment variables
export HTTP_PROXY=http://proxy.company.com:8080
export HTTPS_PROXY=http://proxy.company.com:8080

# Or use pip config
pip config set global.proxy http://proxy.company.com:8080

If your proxy uses a self-signed certificate, point pip to your corporate certificate bundle:

pip config set global.cert /path/to/company-ca-bundle.crt

5. Reinstall pip with ensurepip

If pip itself is broken:

python3 -m ensurepip --upgrade

This reinstalls pip using the bundled wheels. On some systems, especially when switching Python versions, pip loses its SSL context.

6. Use a virtual environment

System-wide pip installations sometimes conflict with the OS certificate store. Create a fresh virtual environment:

python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip setuptools wheel
pip install requests

Virtual environments have their own pip and certificate store, isolated from system conflicts.

Prevention

  • Keep Python updated, especially minor versions.
  • Run pip install --upgrade certifi regularly.
  • Use virtual environments for all projects -- they isolate pip configuration.
  • On corporate networks, set REQUESTS_CA_BUNDLE to the corporate certificate bundle.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro