{"id":"00ea4a849d7f5bf7","repo":"pypa/pip","slug":"missing-dependencies-for-socks-support","errorCode":null,"errorMessage":"Missing dependencies for SOCKS support.","messagePattern":"Missing dependencies for SOCKS support\\.","errorType":"exception","errorClass":"InvalidSchema","httpStatus":null,"severity":"error","filePath":"src/pip/_vendor/requests/adapters.py","lineNumber":67,"sourceCode":"    SSLError,\n)\nfrom .models import Response\nfrom .structures import CaseInsensitiveDict\nfrom .utils import (\n    DEFAULT_CA_BUNDLE_PATH,\n    get_auth_from_url,\n    get_encoding_from_headers,\n    prepend_scheme_if_needed,\n    select_proxy,\n    urldefragauth,\n)\n\ntry:\n    from pip._vendor.urllib3.contrib.socks import SOCKSProxyManager  # type: ignore[assignment]\nexcept ImportError:\n\n    def SOCKSProxyManager(*args: Any, **kwargs: Any) -> None:\n        raise InvalidSchema(\"Missing dependencies for SOCKS support.\")\n\n\nif typing.TYPE_CHECKING:\n    from pip._vendor.urllib3.connectionpool import HTTPConnectionPool\n    from pip._vendor.urllib3.poolmanager import PoolManager as _PoolManager\n\n    from . import _types as _t\n    from .models import PreparedRequest\n\nfrom ._types import is_prepared as _is_prepared\n\nDEFAULT_POOLBLOCK = False\nDEFAULT_POOLSIZE = 10\nDEFAULT_RETRIES = 0\nDEFAULT_POOL_TIMEOUT = None\n\n\ndef _urllib3_request_context(","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/pypa/pip/blob/d7d0d0a39494e28ec1c407bd0680e4a4d1067791/src/pip/_vendor/requests/adapters.py#L49-L85","documentation":"Requests defines a stub SOCKSProxyManager that raises InvalidSchema('Missing dependencies for SOCKS support.') when urllib3.contrib.socks could not be imported (PySocks not installed). The stub is only invoked if a request is routed through a socks:// (or socks4/socks5) proxy, so the error surfaces at request time, not import time.","triggerScenarios":"Calling requests with a SOCKS proxy URL (e.g. proxies={'http':'socks5://127.0.0.1:1080'}) on an environment where the 'PySocks' (import name 'socks') package is not installed; pip vendors requests, so this triggers when pip is told to use a SOCKS proxy without the socks extra.","commonSituations":"Setting ALL_PROXY/HTTP_PROXY to a socks5:// URL without installing PySocks; corporate/privacy proxies (Tor, shadowsocks) used for pip; minimal containers that stripped the socks dependency.","solutions":["Install PySocks: 'pip install pysocks' (or 'pip install requests[socks]').","Switch the proxy to an HTTP/HTTPS proxy if SOCKS is not required.","Ensure the SOCKS URL includes the scheme version, e.g. socks5h:// for remote DNS, after installing the dependency."],"exampleFix":"# before\npip install --proxy socks5://127.0.0.1:1080 pkg\n# -> InvalidSchema: Missing dependencies for SOCKS support.\n\n# after\npip install pysocks\npip install --proxy socks5://127.0.0.1:1080 pkg","handlingStrategy":"validation","validationCode":"try:\n    import socks  # noqa: F401\nexcept ImportError:\n    has_socks = False\nelse:\n    has_socks = True\nif proxy_url.lower().startswith('socks') and not has_socks:\n    raise RuntimeError('install PySocks (pip install requests[socks]) to use a SOCKS proxy')","typeGuard":null,"tryCatchPattern":"from pip._vendor.requests.exceptions import InvalidSchema\ntry:\n    resp = session.get(url, proxies={'http': 'socks5://127.0.0.1:1080'})\nexcept InvalidSchema as e:\n    if 'SOCKS' in str(e):\n        subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'pysocks'])","preventionTips":["Install requests[socks] (PySocks) in images that may use SOCKS proxies.","Detect a socks:// scheme in proxy config and fail fast with a helpful message."],"tags":["requests","proxy","socks","dependencies","network"],"analyzedSha":"d7d0d0a39494e28ec1c407bd0680e4a4d1067791","analyzedAt":"2026-08-04T20:55:04.259Z","schemaVersion":2}