Can't do anything that makes use of ssl/certs under MacOS Catalina 10.15.7 when any version of python is installed under pyenv, only system version

Viewed 209

This is now driving me absolutely mad. I have been trying relentlessly to set up pyenv and pyenv virtualenv to manage 4 different versions of python I need access to in various situations:

3.10.0
3.9.8
3.8.12
system

--Preferably with virtual environments for the first 3. Reason being that I am migrating a few packages to 3.10.0 and updating some of the ones I'm personally working on to make sure my required site-packages are all there for each version.

I've had no trouble accomplishing this task under Ubuntu 20.04, but under MacOS Catalina 10.15.7 I am unable to make this happen with working results.

I used brew to install both pyenv and pyenv virtualenv. Both install with zero errors.

I have followed the most current MacOS specific installation instructions on the respective github repository page for each item (pyenv and pyenv-virtual).

I have read through the Troubleshooting/FAQ and README's for each project. And of course, I've spent hours reading through various issues that seemed similar to my own dilemma here on SO. I've also reviewed the fairly conclusive install guide posted here: https://wilsonmar.github.io/pyenv/

Finally, I have removed all versions of python I successfully installed with pyenv (pyenv uninstall ) and then uninstalled pyenv/pyenv-virtual with brew. Reinstalled both openssl@1.1 and openssl@3 (The only two required casks for pyenv and pyenv-virtual as of this writing according to brew)

Even after reinstalling everything and looking over my .bashrc/.zshrc/.bash_profile, no matter what I do, I am unable to do even the most basic things that utilize ssl/certs.

But of course if I use the system version of python (2.7.16), the same things that fail on my pyenv versions work fine.

Can anyone spot anything that may be off?

catalina10_15_7:~ user$ pyenv --version
pyenv 2.2.0
catalina10_15_7:~ user$ pyenv virtualenv --version
pyenv-virtualenv 1.1.5 (virtualenv unknown)
catalina10_15_7:~ user$ pyenv versions
* system (set by /Users/user/.pyenv/version)
catalina10_15_7:~ user$ pyenv install 3.10.0
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.10.0.tar.xz...
-> https://www.python.org/ftp/python/3.10.0/Python-3.10.0.tar.xz
Installing Python-3.10.0...
patching file aclocal.m4
patching file configure
Hunk #5 succeeded at 10537 (offset -15 lines).
python-build: use readline from homebrew
python-build: use zlib from xcode sdk
Installed Python-3.10.0 to /Users/user/.pyenv/versions/3.10.0

catalina10_15_7:~ user$ pyenv rehash
catalina10_15_7:~ user$ pyenv versions
* system (set by /Users/user/.pyenv/version)
  3.10.0
catalina10_15_7:~ user$ pyenv global 3.10.0
catalina10_15_7:~ user$ python --version
Python 3.10.0
catalina10_15_7:~ user$ cd dev/somegit
catalina10_15_7:somegit user$ ./download.py
Traceback (most recent call last):
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/http/client.py", line 1276, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/http/client.py", line 1322, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/http/client.py", line 1271, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/http/client.py", line 1031, in _send_output
    self.send(msg)
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/http/client.py", line 969, in send
    self.connect()
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/http/client.py", line 1448, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/ssl.py", line 512, in wrap_socket
    return self.sslsocket_class._create(
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/ssl.py", line 1070, in _create
    self.do_handshake()
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/ssl.py", line 1341, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/user/dev/somegit/./download.py", line 56, in <module>
    r = urlopen(manifest)
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/urllib/request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/Users/user/.pyenv/versions/3.10.0/lib/python3.10/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>
catalina10_15_7:somegit user$

catalina10_15_7:somegit user$

catalina10_15_7:somegit user$
catalina10_15_7:somegit user$ cat ~/.bashrc
# .bashrc

# PATH
export PATH="$(brew --prefix sqlite)/bin:\
$(brew --prefix openssl@1.1)/bin:\
$(brew --prefix openssl@3)/bin:\
$(brew --prefix bison)/bin:\
$HOME/Library/Android/sdk/platform-tools:\
$HOME/.pyenv/bin:\
$PATH"

# Exports
export PATH="$HOME/Library/Android/sdk/platform-tools:$PATH"
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"
export LDFLAGS="-L/usr/local/opt/openssl@3/lib"
export CPPFLAGS="-I/usr/local/opt/openssl@3/include"
export LDFLAGS="-L/usr/local/opt/readline/lib"
export CPPFLAGS="-I/usr/local/opt/readline/include"
export LDFLAGS="-L/usr/local/opt/sqlite/lib"
export CPPFLAGS="-I/usr/local/opt/sqlite/include"
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
export LDFLAGS="-L/usr/local/opt/bison/lib"

# pyenv
eval "$(pyenv virtualenv-init -)"
export PYENV_ROOT="$HOME/.pyenv"

# gpip
gpip() {
    PIP_REQUIRE_VIRTUALENV=false pip "$@"
}

# Aliases
alias ls='ls -G'
alias ll='ls -laG'

catalina10_15_7:somegit user$
catalina10_15_7:somegit user$ brew list
==> Formulae
autoconf        dmg2img         libidn2         m4          pcre2           readline        xz
autossh         gettext         libunistring        ntfs-3g-mac     pkg-config      sqlite          zlib
bash            git         libusb          openjdk         pv          squashfs        zstd
bison           gzip            lz4         openssl@1.1     pyenv           tree
ca-certificates     javacc          lzo         openssl@3       pyenv-virtualenv    wget

==> Casks
font-hack-nerd-font
catalina10_15_7:somegit user$
0 Answers
Related