" There was a problem confirming the ssl certificate..." while installing opencv package

Viewed 750

Hi this is a continuation of my first question.I am a beginner in python trying to create a face recognition project with the face recognition and opencv library on Mac M1. I created a new Conda envrionment with the correct configuration for arm64 using:

CONDA_SUBDIR=osx-arm64 conda create -n openCVTest python=3.9 -c conda-forge --override-channel

I activated the environment and did:

conda install -c conda-forge opencv
conda install -c conda-forge face_recognition

I can see face_recognition in pip list, but my code still has an error when I import it. For opencv I didn't see the library installed when I did pip list so I tried to do:

pip install opencv

but it gave me this error:

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/opencv/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/opencv/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/opencv/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/opencv/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/opencv/
Could not fetch URL https://pypi.org/simple/opencv/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/opencv/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping

I don't know if something is wrong with my pip or is it the environment that I set up is not functioning properly, I would really appreciate any help on how to resolve this issue.Thanks in advance.

1 Answers

This is your clue to the problem:

"Can't connect to HTTPS URL because the SSL module is not available."

So your SSL module is missing. This can happen if you compiled python from source without the necessary dependencies, or in some other python environments like anaconda, under the same conditions.

Install the necessary packages from python and ssl. If you're on a debian/ubuntu system, this will be:

sudo apt-get install libssl-dev

If you're on redhat/centos/rocky:

sudo yum install openssl

For any other system, find an install a package for OpenSSL. On windows, make sure the below files are in ..\Anaconda\DLLs and ..\Anaconda\Libarary\bin:

libcrypto-1_1-x64.*
libssl-1_1-x64.*

With the necessary dependencies for SSL taken care of, rebuild your virtual environment. If this doesn't resolve your issue (on unix anyways), consider rebuilding or reinstalling anaconda.

Related