Jump to solution
Verify

The Fix

pip install requests==2.27.0

Based on closed psf/requests issue #4369 · PR/commit linked

Production note: Most teams hit this during upgrades or environment changes. Roll out with a canary and smoke critical endpoints (health, OpenAPI/docs) before 100%.

Jump to Verify Open PR/Commit
@@ -179,3 +179,4 @@ Patches and Suggestions - Matt Liu <[email protected]> (`@mlcrazy <https://github.com/mlcrazy>`_) - Taylor Hoff <[email protected]> (`@PrimordialHelios <https://github.com/PrimordialHelios>`_) +- Arthur Vigil (`@ahvigil <https://github.com/ahvigil>`_) diff --git a/HISTORY.rst b/HISTORY.rst index 89a0b0dc16..e6281c1e77 100644
repro.py
# will generate a barebones zip archive from the contents of this folder mkdir zipapptest # produce a 2 line __main__.py that reproduces the bug cat >zipapptest/__main__.py <<EOF import requests requests.get('https://www.google.com') EOF # I will try to include the requests dependency in the archive pip install -t zipapptest requests # generate an executable zip from the above folder python -m zipapp --python $(which python) zipapptest # try to run the generated archive ./zipapptest.pyz
verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.
fix.md
Option A — Upgrade to fixed release\npip install requests==2.27.0\nWhen NOT to use: Do not use this fix if the application does not run from a zip archive.\n\n

Why This Fix Works in Production

  • Trigger: "__main__", mod_spec)
  • Mechanism: The requests library fails to load CA certs from a zip archive due to incorrect path handling
  • Why the fix works: Resolves the issue by checking whether the default CA certificate bundle is being imported from a zip archive and extracts it to a temporary folder if necessary. (first fixed release: 2.27.0).
Production impact:
  • If left unfixed, the same config can fail only in production (env differences), causing startup failures or partial feature outages.

Why This Breaks in Prod

  • Shows up under Python 3.6 in real deployments (not just unit tests).
  • The requests library fails to load CA certs from a zip archive due to incorrect path handling
  • Surfaces as: Traceback (most recent call last):

Proof / Evidence

  • GitHub issue: #4369
  • Fix PR: https://github.com/psf/requests/pull/4371
  • First fixed release: 2.27.0
  • Reproduced locally: No (not executed)
  • Last verified: 2026-02-09
  • Confidence: 0.85
  • Did this fix it?: Yes (upstream fix exists)
  • Own content ratio: 0.42

Discussion

High-signal excerpts from the issue thread (symptoms, repros, edge-cases).

“Python has supported running packaged zip files since 2.6. The zipapp module newly introduced in python 3 is supposed to make it even easier to create executable python zip archives. As part of this, the contents of the zip archive are adde”
Issue thread · issue description · source

Failure Signature (Search String)

  • "__main__", mod_spec)

Error Message

Stack trace
error.txt
Error Message ------------- Traceback (most recent call last): File "/usr/local/lib/python3.6/runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "/usr/local/lib/python3.6/runpy.py", line 85, in _run_code exec(code, run_globals) File "./zipapptest.pyz/__main__.py", line 2, in <module> File "./zipapptest.pyz/requests/api.py", line 72, in get File "./zipapptest.pyz/requests/api.py", line 58, in request File "./zipapptest.pyz/requests/sessions.py", line 508, in request File "./zipapptest.pyz/requests/sessions.py", line 618, in send File "./zipapptest.pyz/requests/adapters.py", line 407, in send File "./zipapptest.pyz/requests/adapters.py", line 226, in cert_verify OSError: Could not find a suitable TLS CA certificate bundle, invalid path: ./zipapptest.pyz/certifi/cacert.pem

Minimal Reproduction

repro.py
# will generate a barebones zip archive from the contents of this folder mkdir zipapptest # produce a 2 line __main__.py that reproduces the bug cat >zipapptest/__main__.py <<EOF import requests requests.get('https://www.google.com') EOF # I will try to include the requests dependency in the archive pip install -t zipapptest requests # generate an executable zip from the above folder python -m zipapp --python $(which python) zipapptest # try to run the generated archive ./zipapptest.pyz

Environment

  • Python: 3.6

What Broke

HTTPS requests fail with IOError when requests is run from a zip archive.

Why It Broke

The requests library fails to load CA certs from a zip archive due to incorrect path handling

Fix Options (Details)

Option A — Upgrade to fixed release Safe default (recommended)

pip install requests==2.27.0

When NOT to use: Do not use this fix if the application does not run from a zip archive.

Use when you can deploy the upstream fix. It is usually lower-risk than long-lived workarounds.

Fix reference: https://github.com/psf/requests/pull/4371

First fixed release: 2.27.0

Last verified: 2026-02-09. Validate in your environment.

Get updates

We publish verified fixes weekly. No spam.

Subscribe

When NOT to Use This Fix

  • Do not use this fix if the application does not run from a zip archive.

Verify Fix

verify
Re-run the minimal reproduction on your broken version, then apply the fix and re-run.

Did This Fix Work in Your Case?

Quick signal helps us prioritize which fixes to verify and improve.

Prevention

  • Add a TLS smoke test that performs a real handshake in CI (include CA bundle validation and hostname checks).
  • Alert on handshake failures by error string and endpoint to catch cert/CA changes quickly.

Version Compatibility Table

VersionStatus
2.27.0 Fixed

Related Issues

No related fixes found.

Sources

We don’t republish the full GitHub discussion text. Use the links above for context.