{"id":"2a4fd7c1468983b8","repo":"psf/requests","slug":"urllib3-urllib3-version-or-chardet-chard","errorCode":null,"errorMessage":"urllib3 ({urllib3.__version__}) or chardet ({chardet_version})/charset_normalizer ({charset_normalizer_version}) doesn't match a supported version!","messagePattern":"urllib3 \\((.+?)\\) or chardet \\((.+?)\\)/charset_normalizer \\((.+?)\\) doesn't match a supported version!","errorType":"console","errorClass":"RequestsDependencyWarning","httpStatus":null,"severity":"warning","filePath":"src/requests/__init__.py","lineNumber":119,"sourceCode":"    try:\n        cryptography_version_list = list(map(int, cryptography_version.split(\".\")))\n    except ValueError:\n        return\n\n    if cryptography_version_list < [1, 3, 4]:\n        warning = f\"Old version of cryptography ({cryptography_version_list}) may cause slowdown.\"\n        warnings.warn(warning, RequestsDependencyWarning)\n\n\n# Check imported dependencies for compatibility.\ntry:\n    check_compatibility(\n        urllib3.__version__,\n        chardet_version,\n        charset_normalizer_version,\n    )\nexcept (AssertionError, ValueError):\n    warnings.warn(\n        f\"urllib3 ({urllib3.__version__}) or chardet \"\n        f\"({chardet_version})/charset_normalizer ({charset_normalizer_version}) \"\n        \"doesn't match a supported version!\",\n        RequestsDependencyWarning,\n    )\n\n# Attempt to enable urllib3's fallback for SNI support\n# if the standard library doesn't support SNI or the\n# 'ssl' library isn't available.\ntry:\n    try:\n        import ssl\n    except ImportError:\n        ssl = None\n\n    if not getattr(ssl, \"HAS_SNI\", False):\n        from urllib3.contrib import pyopenssl\n","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/psf/requests/blob/414f0513c33883adf6f2b46901d4f0b38a455851/src/requests/__init__.py#L101-L137","documentation":"This is a RequestsDependencyWarning emitted at `import requests` time. On import, requests runs `check_compatibility()` (src/requests/__init__.py:60) which asserts that urllib3 is >= 1.21.1 (and not a 'dev' git build), chardet is >= 3.0.2 and < 8.0.0, or charset_normalizer is >= 2.0.0 and < 4.0.0. If any assert fails or a version string can't be parsed to integers (ValueError), the except at line 118 converts it into this warning rather than crashing, since requests may still work but is running against an untested dependency combination.","triggerScenarios":"Emitted the first time `import requests` runs in a process when: urllib3.__version__ is below 1.21.1 or reports a non-numeric/dev version (e.g. '2.0.0a1', git checkout); chardet.__version__ is outside [3.0.2, 8.0.0); charset_normalizer.__version__ is outside [2.0.0, 4.0.0); or any of those version strings contains non-integer components so int() raises ValueError during parsing.","commonSituations":"Upgrading urllib3 or charset_normalizer independently of requests (e.g. `pip install -U urllib3` pulled a major version an old requests doesn't recognize); an old pinned requests in a requirements file combined with newer transitive deps; conda/pip mixed environments with mismatched packages; installing urllib3 or charset_normalizer from git or a pre-release (alpha/beta version strings fail int parsing); system Python with distro-patched version strings; Lambda/Docker layers shipping their own urllib3 alongside a different requests.","solutions":["Upgrade requests to the latest release so its supported version ranges include your installed deps: pip install -U requests","Reinstall the checked dependencies into requests' supported ranges: pip install -U 'urllib3>=1.21.1' 'charset_normalizer>=2,<4'","Verify what is actually installed in the active environment: pip show requests urllib3 charset_normalizer chardet — and remove duplicate/conflicting copies (e.g. pip uninstall chardet if both detectors are present at odd versions)","Avoid pre-release or git installs of urllib3/charset_normalizer (non-numeric version strings trigger this warning); pin release versions instead","If the environment is a mixed conda+pip install, recreate it or reinstall requests and its deps with a single package manager to eliminate shadowed packages"],"exampleFix":"# before (requirements.txt) — mismatched pins trigger RequestsDependencyWarning\nrequests==2.25.1\nurllib3==2.2.0\n\n# after — let requests own its dependency range\nrequests>=2.32.0\n# (urllib3 and charset_normalizer resolved by requests' own constraints)","handlingStrategy":"validation","validationCode":"# Check dependency compatibility before importing requests in app startup\nimport importlib.metadata as md\n\ndef check_requests_deps():\n    urllib3_v = md.version('urllib3')\n    major, minor, _ = (urllib3_v.split('.') + ['0'])[:3]\n    assert int(major) in (1, 2), f'unsupported urllib3 {urllib3_v}'\n    try:\n        cn = md.version('charset_normalizer')\n    except md.PackageNotFoundError:\n        cn = None\n    try:\n        ch = md.version('chardet')\n    except md.PackageNotFoundError:\n        ch = None\n    assert cn or ch, 'need charset_normalizer or chardet installed'\n\ncheck_requests_deps()","typeGuard":null,"tryCatchPattern":"import warnings\ntry:\n    with warnings.catch_warnings():\n        warnings.simplefilter('error')  # surface RequestsDependencyWarning as an error\n        import requests\nexcept Warning as w:\n    # Incompatible urllib3/chardet/charset_normalizer versions\n    raise SystemExit(f'requests dependency mismatch: {w} — pin compatible versions (pip install -U requests)')","preventionTips":["Pin requests and its transitive deps (urllib3, charset_normalizer/chardet) together in a lock file (pip-tools, poetry, uv) so they can never drift independently.","Never upgrade urllib3 or chardet standalone with pip install -U; upgrade requests itself and let its version constraints pull compatible deps.","Run pip check (or uv pip check) in CI to catch dependency-resolution conflicts before deploy.","Treat RequestsDependencyWarning at import as a real defect: enable -W error::Warning (or a targeted warnings filter) in test runs so the mismatch fails fast instead of silently proceeding.","Avoid mixing conda- and pip-installed copies of urllib3/chardet in the same environment — that is the most common source of unsupported-version mismatches."],"tags":["python","requests","urllib3","dependency-version","charset-normalizer","import-time-warning"],"analyzedSha":"414f0513c33883adf6f2b46901d4f0b38a455851","analyzedAt":"2026-07-31T19:24:57.696Z","schemaVersion":2}