I recently encountered an issue on Windows 11 while trying to install Python packages using pip. The error message indicated a problem with finding a suitable TLS CA certificate bundle, and it turned out to be related to changes made by PostgreSQL to the environment variables.
ERROR: Could not install packages due to an OSError: Could not find a
suitable TLS CA certificate bundle, invalid path: C:\ProgramFiles\PostgreSQL\16\ssl\certs\ca-bundle.crt
Here’s a quick two-step fix that worked for me:
Update the CURL_CA_BUNDLE Variable:
Find the path to the cacert.pem file in your Python installation by running
create a python file and run this:
> import certifi
> print(certifi.where())
This will print the full path to the cacert.pem file.
Update the CURL_CA_BUNDLE Environment Variable: Open the System Properties on your Windows machine. You can do this by right-clicking on "This PC" or "Computer" on your desktop or File Explorer, selecting "Properties," and then clicking on "Advanced system settings."
In the System Properties window, click on the “Environment Variables…” button.
Under the “System variables” section, find the CURL_CA_BUNDLE variable. If it doesn't exist, you can create a new one.
Edit the CURL_CA_BUNDLE variable and set its value to the full path of the cacert.pem file obtained in step 1.
Restart Your PC: After updating the environment variable, restart your computer to apply the changes.
After completing these steps, try running your pip install command again to see if the issue is resolved:
This workaround solved my issue, and I hope it helps you too!
/usr/local/lib/python3.6/dist-packages/certifi/cacert.pem
I get the same old error:ERROR: Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path: /home/yosra/Desktop/CERT.RSA
– Footrope