Install & Compatibility
Where this runs
tested against v0.18.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.940 runs
installs and imports cleanly · install 0.0s · import 0.000s · 31.7MB
glibcpy 3.10–3.940 runs
installs and imports cleanly · install 2.5s · import 0.000s · 34MB
31MB installed
● package 31MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
PACSession
✓ from pypac import PACSession
✗ from pypac import PACProxyResolver
get_pac
✓ from pypac import get_pac
pac_context_for_url
✓ from pypac import pac_context_for_url
This quickstart demonstrates how to use PyPAC's `PACSession` to automatically resolve and apply proxy settings for `requests` calls. `PACSession` handles PAC file discovery (e.g., via WPAD) and proxy resolution transparently. If no PAC file is found via auto-discovery, it will default to direct connections.
from pypac import PACSession
import requests
try:
# Auto-discovers PAC files or manually specify via PACSession(pac_url='...')
with PACSession() as session:
# Example usage with a public IP checker (ensure it's HTTP/HTTPS)
response = session.get('http://httpbin.org/ip')
response.raise_for_status()
print(f"Using PACSession, IP is: {response.json()['origin']}")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
Debug
Known issues
gotchaWhen using `PACSession` for `requests` integration, do not attempt to set `session.proxies` manually. `PACSession` transparently handles proxy resolution and setting, and directly modifying `session.proxies` will override or conflict with its functionality.fixRely on `PACSession` to manage proxies automatically. If you need to inspect proxy usage, check `response.request.proxy_url` after a request.
affects: All versions
gotchaPAC file auto-discovery (WPAD) can be unreliable or disabled in some network environments (e.g., corporate networks, firewalls). If `PACSession` or `PACProxyResolver` cannot find a PAC file, it will fall back to a direct connection, which might not be desired.fixIf auto-discovery fails, explicitly provide the PAC file URL or path: `PACSession(pac_url='http://your.proxy.com/proxy.pac')` or `PACProxyResolver(url='...')`.
affects: All versions
gotchaPython 2.7 support is deprecated and requires the `dukpy` library for PAC script evaluation, which itself has specific installation and versioning requirements for older Python. For modern use, Python 3 is strongly recommended.fixMigrate to Python 3. If Python 2.7 is mandatory, ensure `dukpy>=0.2.3` is installed and be aware of potential platform-specific issues.
affects: 0.16.2 and older on Python 2.7
Upgrade
Version history
0.18.3latest on PyPI · released May 15, 2026
Audit
Dependencies
requestsoptionalRequired for PACSession integration with the popular requests library.
dukpyoptionalRequired for PAC script evaluation on Python 2.7.