{"id":24110,"library":"netifaces-plus","title":"netifaces-plus","description":"A portable library to retrieve network interface information (IP addresses, MAC addresses, gateways, etc.) on Unix, Windows, and macOS. Version 0.12.5 supports Python >=3.6. Fork of the unmaintained netifaces with modern Python support and additional features. Released irregularly.","status":"active","version":"0.12.5","language":"python","source_language":"en","source_url":"https://github.com/tsukumijima/netifaces-plus","tags":["networking","network-interfaces","ip-address","mac-address","gateway"],"install":[{"cmd":"pip install netifaces-plus","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"note":"The library name in PyPI is 'netifaces-plus' but the import package is 'netifaces'. Do not use the hyphenated name.","wrong":"import netifaces_plus","symbol":"netifaces","correct":"import netifaces"},{"note":"The function to list interface names is `interfaces()`, not `networks()`.","wrong":"netifaces.networks()","symbol":"interfaces","correct":"netifaces.interfaces()"},{"note":"`gateways()` is a top-level function returning all gateway info. There is no `default_gateway()`.","wrong":"netifaces.default_gateway()","symbol":"gateways","correct":"netifaces.gateways()"}],"quickstart":{"code":"import netifaces\n\n# List all network interface names\nifaces = netifaces.interfaces()\nprint('Interfaces:', ifaces)\n\n# Get addresses for a specific interface (e.g., 'eth0' or 'en0')\nif ifaces:\n    iface = ifaces[0]\n    addrs = netifaces.ifaddresses(iface)\n    print(f'Addresses for {iface}:', addrs)\n\n# Get default gateways\nprint('Gateways:', netifaces.gateways())","lang":"python","description":"Basic usage: list interfaces, get addresses for first interface, and show gateways."},"warnings":[{"fix":"Use 'import netifaces'.","message":"The PyPI package name is 'netifaces-plus' but the Python import is 'netifaces'. This often confuses users who try 'import netifaces_plus'.","severity":"gotcha","affected_versions":"all"},{"fix":"Check if address family exists: `netifaces.AF_INET in addrs`.","message":"On some platforms (e.g., Windows), 'ifaddresses(MY_IFACE)' may return empty or partial data if the interface is down or not fully initialized. Always handle missing keys.","severity":"gotcha","affected_versions":"all"},{"fix":"Upgrade Python to 3.6+ or use 'pip install netifaces-plus<0.12.4'.","message":"In version 0.12.4, the library dropped support for Python 3.5 and below. Users on older Python must pin to an older release.","severity":"breaking","affected_versions":">=0.12.4"},{"fix":"Access default IPv4 gateway with `netifaces.gateways()['default'][netifaces.AF_INET]`.","message":"The 'gateways()' function returns a dict where keys are address families (e.g., AF_INET, AF_INET6) and values are lists. The default gateway is the first element of the list, not a separate key.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use 'import netifaces' instead of 'import netifaces_plus'.","cause":"User tried to import the package with the PyPI name (netifaces-plus) as the module name.","error":"ModuleNotFoundError: No module named 'netifaces_plus'"},{"fix":"Ensure you installed netifaces-plus (not netifaces) and check the version: `pip show netifaces-plus`.","cause":"The module might not be the real netifaces-plus (perhaps a stale or different package).","error":"AttributeError: module 'netifaces' has no attribute 'interfaces'"},{"fix":"Check with `if netifaces.AF_INET in addrs` before accessing addrs[netifaces.AF_INET].","cause":"The interface does not have an IPv4 address (e.g., no IP assigned).","error":"KeyError: 2 (or AF_INET not found)"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}