Valizada's blog

python openssl mac os

How Mac OS Catalina update broke my pip, python set up.

I finally decided it is time to upgrade Mac OS Catalina, the whole process was in general very smooth. Of course small glitches do come around as usual due to the breaking changes OS X brings in every now and then.

So, I had my Pipfile on hand as in below example.

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[dev-packages]
pylint = ">=2.0.0"

[packages]
openpyxl = "==2.5.12"
requests = "==2.22.0"
sshtunnel = "==0.1.5"

[requires]
python_version = "3.7"

Unfortunately trying pipenv installation greeted me SSL error: Could not fetch URL https://pypi.org/simple/requests/: There was a problem confirming the ssl certificate

?  scripts git:(master) ? pipenv install --skip-lock
Password:
Installing dependencies from Pipfile?
An error occurred while installing requests==2.22.0! Will try again.
An error occurred while installing xmltodict==0.12.0! Will try again.
An error occurred while installing pylint==2.4.4! Will try again.
An error occurred while installing paramiko==2.6.0! Will try again.
An error occurred while installing sshtunnel==0.1.5! Will try again.
  ??   ???????????????????????????????? 7/7 ? 00:00:08
Installing initially failed dependencies?
  ?  ???????????????????????????????? 5/5 ? 00:00:41
[pipenv.exceptions.InstallError]:   File "/Library/Python/3.7/site-packages/pipenv/cli/command.py", line 254, in install
[pipenv.exceptions.InstallError]:       editable_packages=state.installstate.editables,
[pipenv.exceptions.InstallError]:   File "/Library/Python/3.7/site-packages/pipenv/core.py", line 1874, in do_install
[pipenv.exceptions.InstallError]:       keep_outdated=keep_outdated
[pipenv.exceptions.InstallError]:   File "/Library/Python/3.7/site-packages/pipenv/core.py", line 1253, in do_init
[pipenv.exceptions.InstallError]:       pypi_mirror=pypi_mirror,
[pipenv.exceptions.InstallError]:   File "/Library/Python/3.7/site-packages/pipenv/core.py", line 862, in do_install_dependencies
[pipenv.exceptions.InstallError]:       _cleanup_procs(procs, False, failed_deps_queue, retry=False)
[pipenv.exceptions.InstallError]:   File "/Library/Python/3.7/site-packages/pipenv/core.py", line 681, in _cleanup_procs
[pipenv.exceptions.InstallError]:       raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: ['Collecting requests==2.22.0', '  Could not fetch URL https://pypi.org/simple/requests/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host=\'pypi.org\', port=443): Max retries exceeded with url: /simple/requests/ (Caused by SSLError("Can\'t connect to HTTPS URL because the SSL module is not available.")) - skipping']
[pipenv.exceptions.InstallError]: ["WARNING: The directory '/Users/valizadaf/Library/Caches/pipenv/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.", 'WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.', "WARNING: The directory '/Users/fiz/Library/Caches/pipenv' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.", '  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/requests/', '  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/requests/', '  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/requests/', '  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/requests/', '  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/requests/', '  ERROR: Could not find a version that satisfies the requirement requests==2.22.0 (from versions: none)', 'ERROR: No matching distribution found for requests==2.22.0']
ERROR: ERROR: Package installation failed...

After searching around, I found this github issue https://github.com/envoyproxy/envoy/issues/2395 mentioning that Mac OS switched away from OpenSSL to LibreSSL.

brew update && brew upgrade
brew uninstall --ignore-dependencies openssl
brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb