1

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.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36

1 Answers1

0

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.

Dillon Davis
  • 6,679
  • 2
  • 15
  • 37
  • Sorry for asking again but I just want to be sure, so I install the libscrypto and libssl packages, but where should it be installed and is there a way for me to verify that the installation was successful and in the right place? – Ambrose Ling Feb 02 '22 at 19:52
  • @AmbroseLing run `openssl version` from your terminal- if it doesn't error, you should be fine – Dillon Davis Feb 02 '22 at 21:17
  • If it still doesn't work, its just a matter of your python interpreter having been built prior to the required deps being installed. You'll be able to `import ssl` and/or `import _ssl` from the interpreter when things are "working" – Dillon Davis Feb 02 '22 at 21:19
  • There is no error when I ran openssl version, I did brew reinstall openssl on my terminal, but it doesn't seem to be working, it still tells me that there's a missing ssl module when I try to install opencv. I downloaded the libcrypto-1_1-x64.* libssl-1_1-x64.* files, where should those files be stored? or is there any way I can move forward with this? – Ambrose Ling Feb 02 '22 at 22:10
  • You could try reinstalling python `brew reinstall python` - [source](https://stackoverflow.com/a/58280749/6221024). I'm not sure if this will affect anaconda though. Try importing `ssl` in a normal python interpreter, just to see (its builtin, if deps are met) – Dillon Davis Feb 02 '22 at 22:19
  • thank you I think I resolved the issue for now, I created a new python virtual environment and downloaded the libraries there through pycharm – Ambrose Ling Feb 03 '22 at 06:04