{"id":23184,"library":"win-inet-pton","title":"win-inet-pton","description":"Provides native inet_pton and inet_ntop implementations for Windows using ctypes. Version 1.1.0 is current; maintenance mode with rare updates.","status":"active","version":"1.1.0","language":"python","source_language":"en","source_url":"https://github.com/hickeroar/win_inet_pton","tags":["windows","inet_pton","inet_ntop","socket","compatibility","ctypes"],"install":[{"cmd":"pip install win-inet-pton","lang":"bash","label":"Install via pip"}],"dependencies":[],"imports":[{"note":"Standard import after installing win-inet-pton.","symbol":"inet_pton","correct":"from win_inet_pton import inet_pton"},{"note":"Standard import for inet_ntop.","symbol":"inet_ntop","correct":"from win_inet_pton import inet_ntop"},{"note":"Do not import socket from win_inet_pton; instead assign the function to socket.inet_pton.","wrong":"from win_inet_pton import socket","symbol":"socket","correct":"import socket; socket.inet_pton = inet_pton"}],"quickstart":{"code":"import socket\nfrom win_inet_pton import inet_pton, inet_ntop\n\n# Monkey-patch socket module to add missing functions on Windows\nsocket.inet_pton = inet_pton\nsocket.inet_ntop = inet_ntop\n\n# Now you can use inet_pton and inet_ntop directly via socket\nprint(socket.inet_pton(socket.AF_INET, '8.8.8.8'))","lang":"python","description":"Monkey-patches socket module on Windows so inet_pton and inet_ntop work the same as on Unix."},"warnings":[{"fix":"Wrap import in a platform check.","message":"This library is Windows-only. Importing it on non-Windows systems will raise an ImportError unless you guard it. Always use the check `if sys.platform == 'win32':` before importing.","severity":"gotcha","affected_versions":"all"},{"fix":"Apply the patch in a single location, e.g., at the start of your application.","message":"The library monkey-patches the built-in socket module. If you assign the functions via `socket.inet_pton = inet_pton`, ensure you do it only once to avoid double-patching. Doing it repeatedly is harmless but confusing.","severity":"gotcha","affected_versions":"all"},{"fix":"For Python 3.4+, remove the dependency; the functions are built-in.","message":"Python 3.4+ on Windows includes official `inet_pton` support in the socket module. This library is only needed for Python 2.7 or earlier Python 3 versions. For modern Python, consider dropping it.","severity":"deprecated","affected_versions":">=3.4"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run `pip install win-inet-pton` (note hyphen in package name).","cause":"Library not installed via pip.","error":"ImportError: No module named win_inet_pton"},{"fix":"After importing, assign: `socket.inet_pton = inet_pton` (and optionally inet_ntop).","cause":"Import succeeded but monkey-patching was not performed.","error":"AttributeError: module 'socket' has no attribute 'inet_pton'"},{"fix":"Ensure you pass the correct family (socket.AF_INET or socket.AF_INET6) and a valid IP string.","cause":"Using `socket.inet_pton` with an incorrect address family or invalid address string.","error":"OSError: [WinError 10042] An address incompatible with the requested protocol was used"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}