Pip Install Fails With “connection Error: [ssl: CERTIFICATE_VERIFY_FAILED] Certificate Verify Failed (_ssl.c:598)”

This error typically appears when the SSL certificate installed on your system cannot be verified by pip. This could be due to a variety of reasons, such as outdated SSL certificates or network issues.

Here are a few steps you can take to resolve this issue:

  1. Upgrade pip: Run the following command to upgrade your pip version to the latest release:

    python -m pip install --upgrade pip
  2. Disable SSL verification: If you’re working in a trusted environment, you can try disabling SSL verification. However, keep in mind that this may pose security risks.

    python -m pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org <package-name>
  3. Update SSL certificates manually:

    • Download the ‘cacert.pem’ file from the curl website: https://curl.se/ca/cacert.pem

    • Locate your Python installation directory. In it, find the ‘Lib’ directory.

    • Within the ‘Lib’ directory, create a new subdirectory called ‘certifi’.

    • Move the downloaded ‘cacert.pem’ file into the newly created ‘certifi’ directory.

    • Set an environment variable called ‘SSL_CERT_FILE’ with the path to the ‘cacert.pem’ file.

      On Windows:

      setx SSL_CERT_FILE "<Python-installation-path>\Lib\certifi\cacert.pem"

      On macOS/Linux:

      export SSL_CERT_FILE="<Python-installation-path>/lib/certifi/cacert.pem"
  4. Temporarily disable antivirus/firewall: Sometimes, antivirus or firewall software can interfere with SSL certificate verification. Temporarily disable these security tools and try again.

  5. Use a different network: If you’re behind a proxy or on a restricted network, try using a different network to see if the issue persists.

If none of the above solutions work, you should consult with your system administrator or network provider for further assistance.

About the Author Rex

I'm a passionate tech blogger with an insatiable love for programming! From my early days tinkering with code, I've delved into web dev, mobile apps, and AI. Sharing insights and tutorials with the world is my joy, connecting me to a global community of like-minded tech enthusiasts. Python holds a special place in my heart, but I embrace all challenges. Constantly learning, I attend tech conferences, contribute to open-source projects, and engage in code review sessions. My ultimate goal is to inspire the next generation of developers and contribute positively to the ever-evolving tech landscape. Let's code together!