{"id":2066,"library":"ifaddr","title":"ifaddr Library","description":"ifaddr is a small, cross-platform Python library designed for enumerating network interfaces and their associated IP addresses. It supports Linux, OS X, Windows, and is expected to work on other BSD derivatives and Solaris/Illumos. Released under the MIT License, the current version 0.2.0 (June 2022) works with Python 3.9+ and requires no compilation, simplifying installation.","status":"active","version":"0.2.0","language":"python","source_language":"en","source_url":"https://github.com/pydron/ifaddr","tags":["network","IP","address","interface","cross-platform","enumeration"],"install":[{"cmd":"pip install ifaddr","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Runtime environment. Requires Python 3.9+ as of version 0.2.0.","package":"python","optional":false}],"imports":[{"symbol":"get_adapters","correct":"import ifaddr\nadapters = ifaddr.get_adapters()"}],"quickstart":{"code":"import ifaddr\n\n# Get all network adapters\nadapters = ifaddr.get_adapters()\n\nfor adapter in adapters:\n    print(f\"IPs of network adapter {adapter.nice_name}\")\n    if adapter.ips:\n        for ip in adapter.ips:\n            # ip.ip will be a string for IPv4, and a tuple (ip_str, flowinfo, scope_id) for IPv6\n            print(f\"  {ip.ip}/{ip.network_prefix}\")\n    else:\n        print(\"  No IPs configured\")\n\n# To include interfaces without configured IP addresses:\n# adapters_with_unconfigured = ifaddr.get_adapters(include_unconfigured=True)\n","lang":"python","description":"This example demonstrates how to retrieve all network adapters and iterate through their configured IP addresses. It also shows how to include unconfigured adapters if needed."},"warnings":[{"fix":"Upgrade to Python 3.7+ (preferably 3.9+ as per the latest README) if using ifaddr 0.2.0 or newer.","message":"Version 0.2.0 dropped support for Python 3.6.","severity":"breaking","affected_versions":"0.2.0 and later"},{"fix":"Use `ifaddr.get_adapters(include_unconfigured=True)` to retrieve all interfaces, regardless of IP configuration.","message":"By default, `ifaddr.get_adapters()` only returns interfaces with configured IP addresses. To include interfaces without any assigned IP, pass `include_unconfigured=True`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Be aware that `ip.ip` for IPv6 addresses is a tuple. Access the string representation as `ip.ip[0]` if only the address string is needed.","message":"For IPv6 addresses, the `ip.ip` attribute returns a three-tuple: `(ip_address_string, flowinfo, scope_id)`, not just a string, which might require unpacking or specific handling.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Prefer `adapter.nice_name` for displaying adapter names to users, especially on Windows.","message":"On Windows, the `adapter.name` property returns a UUID string, not a human-readable name. Use `adapter.nice_name` for a more descriptive identifier.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consider `netifaces` if more in-depth interface details (e.g., multicast addresses, status flags) are required, acknowledging its compilation dependency. For a subset of `netifaces` functionality, explore `ifaddr.netifaces` module.","message":"While `ifaddr` is lightweight and doesn't require compilation, the `netifaces` library offers more comprehensive network interface information. As of `ifaddr` 0.2.0, an equivalent to `netifaces.interfaces()` is available at `ifaddr.netifaces.interfaces()`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"search_vec":"'0.2.0':47 '2022':49 '3.9':53 'address':21,62 'associ':19 'bsd':35 'compil':57 'cross':8,65 'cross-platform':7,64 'current':45 'deriv':36 'design':12 'enumer':14,67 'expect':30 'ifaddr':1,3 'instal':59 'interfac':16,63 'ip':20,61 'june':48 'librari':2,11 'licens':43 'linux':24 'mit':42 'network':15,60 'os':25 'platform':9,66 'python':10,52 'releas':39 'requir':55 'simplifi':58 'small':6 'solaris/illumos':38 'support':23 'version':46 'window':27 'work':32,50 'x':26","created_at":"2026-04-09T18:42:04.011013+00:00","updated_at":"2026-04-16T15:41:34.670009+00:00","problems":[{"fix":"Install the 'ifaddr' package using pip: `pip install ifaddr`","cause":"The 'ifaddr' package is not installed in the Python environment where the code is being executed.","error":"ModuleNotFoundError: No module named 'ifaddr'"},{"fix":"Ensure `ifaddr.get_adapters()` is spelled correctly. If a local file named `ifaddr.py` exists in your project directory, rename it to avoid conflicting with the installed library. The correct import and usage pattern is typically: `import ifaddr; adapters = ifaddr.get_adapters()`.","cause":"The `get_adapters` function is either misspelled, or a local Python file named `ifaddr.py` is shadowing the installed 'ifaddr' package, causing Python to import the local file instead of the library.","error":"AttributeError: module 'ifaddr' has no attribute 'get_adapters'"},{"fix":"Access the IP address using the `ip` attribute: `ip_object.ip` (e.g., `print(ip.ip)`).","cause":"Users attempting to access the IP address from an `ifaddr.IP` object often use a common attribute name like 'address', but the library exposes the IP address value via the 'ip' attribute.","error":"AttributeError: 'ifaddr.IP' object has no attribute 'address'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":"0.2.0","cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/pydron/ifaddr","docs":null,"changelog":null,"pypi":"https://pypi.org/project/ifaddr/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-28","last_verified":"2026-08-28","next_check":"2026-07-28","install_tag":null}}