pip install fails with "connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)"
Installing Python Packages with Pip: Fixing SSL Certificate Verify Failed Error
If you're new to Python and facing issues with installing packages using pip on Windows 7, chances are you might encounter the dreaded "connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)" error. Don't worry, this guide will walk you through common scenarios and provide easy solutions to fix this problem. 💻🔧
Understanding the Problem
The SSL certificate verification failed error occurs when pip is unable to verify the SSL certificate of the source URL it's trying to access. This typically happens due to various reasons, such as:
Outdated version of pip
Antivirus or firewall blocking the SSL certificate verification
Network proxy issues
Missing SSL certificates on your system
It's important to understand that this error can occur not only when installing a specific package (like linkchecker in this case) but also when installing any package using pip.
Troubleshooting Steps and Solutions
To fix the SSL certificate verify failed error, follow these simple steps:
1. Update pip
Using an outdated version of pip can cause compatibility issues and SSL certificate verification failures. To update pip, open a command prompt and run the following command:
pip install --upgrade pip
This command will fetch and install the latest version of pip.
2. Configure Trusted Root Certificate Authority
If your company network has a Trusted Root Certificate Authority in place (such as for monitoring TLS traffic), it's possible that it's interfering with pip's SSL certificate verification. To address this issue, you can try configuring pip to trust the root certificate authority used by your company.
Run the following command to download the root certificate authority:
pip config set global.cert "/path/to/your/root_certificate.crt"
Make sure to replace /path/to/your/root_certificate.crt
with the path to the root certificate authority file on your system.
3. Disable SSL Verification (Not Recommended)
As a last resort, you can temporarily disable SSL certificate verification. However, this is not recommended as it poses security risks. Only consider this option if you're confident in the source you're installing packages from.
To disable SSL verification, run the following command:
pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org packagename
Replace packagename
with the name of the package you're trying to install.
4. Check Firewall and Antivirus Settings
Firewalls and antivirus software sometimes block connections and SSL certificate verification. Temporarily disabling them or adding exceptions for pip in your firewall and antivirus settings can help resolve the issue.
5. Check Network Proxy Settings
If you're behind a network proxy, it's possible that the proxy is causing the SSL certificate verification failure. Contact your network administrator or IT support to ensure that the proxy settings are configured correctly for pip.
Wrapping Up
By following these troubleshooting steps, you should be able to resolve the "connection error: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:598)" issue when using pip to install Python packages. Remember to keep your pip version up-to-date, configure trusted root certificate authorities if necessary, and check your firewall, antivirus, and network proxy settings.
If you found this guide helpful, have experienced a different issue, or have any questions, feel free to share your thoughts in the comments below. Happy coding! 🐍💻