jeffdaily / parasail-python

Python bindings for the parasail C library.
Other
87 stars 17 forks source link

install failed with python 3.7 on MacOS (SSLCertVerificationError) #25

Open rderelle opened 5 years ago

rderelle commented 5 years ago

I am trying to install parasail on my computer but it does not seem to work. I am using python 3.7 on Mac OS.

with the following command:

python3 setup.py install

I get the following message running install parasail/libparasail.dylib not found, attempting to build Downloading latest parasail master URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)')) Will retry in 10 seconds URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)')) Will retry in 10 seconds URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)')) Will retry in 10 seconds ...

I'm also getting an error message when trying to install parasail via pip:

pip3 install parasail

Collecting parasail Using cached https://files.pythonhosted.org/packages/64/e5/b7b0ab11296923be15dbdbcfb4dd79dc427b5b52a7de9716aa64548afdf7/parasail-1.1.12.tar.gz Requirement already satisfied: numpy in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (from parasail) (1.14.5) Building wheels for collected packages: parasail Running setup.py bdist_wheel for parasail ... error Complete output from command /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7 -u -c "import setuptools, tokenize;file='/private/var/folders/qz/mh9673t94kd7t06bzj7p322h34gb9n/T/pip-install-ch1b64sh/parasail/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d /private/var/folders/qz/mh9673t94kd7t06bzj7p322h34gb9n/T/pip-wheel-k3i38vrh --python-tag cp37: running bdist_wheel parasail/libparasail.dylib not found, attempting to build Downloading latest parasail master URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)')) Will retry in 10 seconds URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)')) Will retry in 10 seconds URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)')) ...

thanks !

jeffdaily commented 5 years ago

This isn't really a problem with parasail-python but a problem with your Python install on OSX. Take a look at https://stackoverflow.com/a/42334357 and see if that has a solution for you.

rderelle commented 5 years ago

Thanks. You are right (install was flawless on my linux desktop).

I have managed to install parasail on my Mac by adding the following code to the setup.py file:

import os, ssl
if (not os.environ.get('PYTHONHTTPSVERIFY', '') and
    getattr(ssl, '_create_unverified_context', None)): 
    ssl._create_default_https_context = ssl._create_unverified_context
jeffdaily commented 5 years ago

So I understand you performed a work-around of not verifying SSL certs instead of fixing your python install by running something like /Applications/Python\ 3.6/Install\ Certificates.command, or I guess in your case since you're running 3.7 it might be /Applications/Python\ 3.7/Install\ Certificates.command (see my stackoverflow link from previous comment)? I don't plan on upstreaming your work-around if the issue isn't really parasail but rather the python install not being complete or correct. I guess it doesn't really matter; I'm just glad you managed to get your install working!

HenrikBengtsson commented 5 years ago

FWIW, I ran into this issue with an old Python 2.7.9 that has outdated SSL certs. The workaround was to disable SSL verification while installing parasail:

WARNING: disabling SSL verification is considered unsafe

$ pip install numpy
$ PYTHONHTTPSVERIFY=0 pip install parasail

Comment: By installing 'numpy' first, you can restrict PYTHONHTTPSVERIFY=0 to only the installation of 'parasail' itself.

blaiseli commented 4 years ago

Also encountered this issue with a locally-compiled python 3.8.0 on Linux (on a computing cluster running centos). I don't have this problem when trying to install other packages.

Based on suggestions found on the internet, I tried the following before re-trying to install parasail:

python3.8 -m pip install -U --force-reinstall certifi setuptools

This didn't solve the problem.

Using PYTHONHTTPSVERIFY=0 didn't seem to change anything either.

Edit (24/11/2019)

Actually, I have the same issue with the python 3.7.2 installed by the system administrators of the cluster (in the form of environment modules). No problem with python 3.6.0.

I could localize the certificates for python 3.6 based on this stackoverflow answer:

$ python3.6
Python 3.6.0 (default, Feb  5 2018, 13:41:37) 
[GCC 4.9.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.get_default_verify_paths().openssl_cafile
'/etc/pki/tls/cert.pem'

I then used this one to fix it for python 3.8:

export REQUESTS_CA_BUNDLE=/etc/pki/tls/cert.pem
export SSL_CERT_FILE=/etc/pki/tls/cert.pem
python3.8 -m pip install parasail

This worked for me.