Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not install packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle, invalid path

Tags:

python

pip

ssl

I get this 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

When I run: $ virtualenv venv

So I put a random CERT.RSA on the Desktop which worked and I created my virtual environment, but then when I run: pip install -r requirements.txt

I got this one:

Could not install packages due to an EnvironmentError: HTTPSConnectionPool(host='github.com', port=443): Max retries exceeded with url: /KristianOellegaard/django-hvad/archive/2.0.0-beta.tar.gz (Caused by SSLError(SSLError(0, 'unknown error (_ssl.c:3715)'),))

I feel that these 2 errors are linked to each other, but I want to know how can I fix the first one?

like image 978
yosra Avatar asked Jun 24 '19 14:06

yosra


People also ask

How do I get TLS CA certificate bundle?

You can contact the customer support team of your vendor or CA and request them to provide the CA bundle. If you have bought your SSL certificate from RapidSSLonline.com, you can easily access the CA bundle from here.

What is TLS CA certificate bundle?

CA Bundle is the file that contains root and intermediate certificates. Together with your server certificate (issued specifically for your domain), these files complete the SSL chain of trust. The chain is required to improve the compatibility of the certificates with web browsers, email clients, and mobile devices.

What is update CA certificates?

update-ca-certificates is a program that updates the directory /etc/ssl/certs to hold SSL certificates and generates ca-certificates. crt, a concatenated single-file list of certificates. It reads the file /etc/ca-certificates.


4 Answers

If you're on Mac (mine is 10.13.6), use the following command:

(security find-certificate -a -p ls /System/Library/Keychains/SystemRootCertificates.keychain &&        security find-certificate -a -p ls /Library/Keychains/System.keychain) > $HOME/.mac-ca-roots

Then do modify .bashrc with

export REQUESTS_CA_BUNDLE="$HOME/.mac-ca-roots"

Then do

$ source ~/.bashrc
like image 79
xxks-kkk Avatar answered Oct 20 '22 13:10

xxks-kkk


You need to allow pip to reference to the correct certificate. check the certificate first;

python -c "import certifi; print(certifi.where())"

Then first test it manually;

pip install -r requirements.txt --cert=<the above certificate path>

If that works fine, then update this path on pip.conf file located at $HOME/.pip/pip.conf (or %APPDATA%\pip\pip.ini on Windows). e.g.

[global]
cert = /usr/local/share/ca-certificate/mycert.crt
like image 42
Anum Sheraz Avatar answered Oct 20 '22 13:10

Anum Sheraz


In Windows 10, 1. Find the location of certifi with following commands to check if installed already

import certifi
certifi.where()
  1. Note down the path of cacert.pem file

  2. Search for the pip.ini file in windows explorer and edit the file in notepad and set the path = <file path of cacert.pem >

like image 10
Prasath Kumar Ramachandran Avatar answered Oct 20 '22 13:10

Prasath Kumar Ramachandran


I received this error while running the command as "pip install flask" in Pycharm.

If you look at the error, you will see that the error points out to "packages due to an EnvironmentError: Could not find a suitable TLS CA certificate bundle -- Invalid path".

I solved this by removing the environment variable "REQUESTS_CA_BUNDLE" OR you can just change the name of the environment variable "REQUESTS_CA_BUNDLE" to some other name.

Restart your Pycharm and this should be solved.

Thank you !

like image 1
Anurag Avatar answered Oct 20 '22 14:10

Anurag