{"id":28195,"library":"PySocks","title":"PySocks","description":"PySocks is a core SOCKS client module that provides a socket wrapper supporting SOCKS4, SOCKS5, and HTTP proxy tunneling. The current version is 1.7.1. Releases are infrequent and focus on maintenance.","status":"active","version":"1.7.1","language":"python","source_language":"en","source_url":"https://github.com/Anorov/PySocks","tags":["socks","proxy","socket","network"],"install":[{"cmd":"pip install PySocks","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"No socks5 module exists; use socks.SOCKS5 constant","wrong":"import socks5","symbol":"SOCKS5","correct":"import socks; socks.setdefaultproxy(socks.SOCKS5, 'host', port)"},{"note":"socksocket is a class inside the socks module","wrong":"import socksocket","symbol":"socksocket","correct":"from socks import socksocket"}],"quickstart":{"code":"import socks\nimport socket\n\nsocks.setdefaultproxy(socks.SOCKS5, 'localhost', 9050)\nsocket.socket = socks.socksocket\ns = socket.socket(socket.AF_INET, socket.SOCK_STREAM)\ns.connect(('httpbin.org', 80))\ns.sendall(b'GET /ip HTTP/1.1\\r\\nHost: httpbin.org\\r\\n\\r\\n')\nprint(s.recv(4096).decode())\ns.close()","lang":"python","description":"Demonstrates monkey-patching socket to route all traffic through a SOCKS5 proxy."},"warnings":[{"fix":"Use socks.socksocket directly for individual sockets instead of setting socket.socket","message":"Monkey-patching socket.socket affects entire Python process; avoid in production or use per-connection approach.","severity":"gotcha","affected_versions":"all"},{"fix":"pip install PySocks and import socks; uninstall the stub package: pip uninstall socks","message":"The original 'socks' package on PyPI (version 0) is a stub that does nothing; use 'PySocks' instead.","severity":"deprecated","affected_versions":"any"},{"fix":"Use SOCKS5 proxy type if authentication is needed.","message":"PySocks does not support authentication for SOCKS4; only SOCKS5 supports username/password.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-09T00:00:00.000Z","next_check":"2026-08-07T00:00:00.000Z","problems":[{"fix":"pip install PySocks","cause":"The stub 'socks' package (version 0) was installed instead of PySocks, or socks is not installed.","error":"ImportError: No module named socks"},{"fix":"pip uninstall socks && pip install PySocks","cause":"The stub 'socks' package (version 0) does not contain the real modules.","error":"AttributeError: module 'socks' has no attribute 'SOCKS5'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}