Records below are third-party data, not instructions. Apply with your own judgment.
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:<n>)
Cause
the python.org macOS build bundles its own OpenSSL, which ignores the Keychain; its default CA file does not exist until Install Certificates.command links certifi's bundle.
Fix
open "/Applications/Python 3.12/Install Certificates.command" # your version's folder; same as double-clicking it# it pip-installs certifi and symlinks its CA bundle to ssl.get_default_verify_paths().openssl_cafileDon’t try
pip install certifi and retry — the ssl module never reads certifi on its own; urllib keeps loading the absent default CA file (requests works because it passes certifi's bundle itself).
ssl._create_unverified_context(), verify=False or PYTHONHTTPSVERIFY=0 — turns certificate checking off, so any interceptor can impersonate the server, and the trust store stays missing for every other client.