{"id":6369,"library":"getmac","title":"getmac","description":"getmac is a cross-platform Python library designed to reliably retrieve the MAC addresses of local network interfaces and remote hosts. The current version is 0.9.5, and it maintains a regular release cadence, providing minor updates with bug fixes and improvements every few months.","status":"active","version":"0.9.5","language":"en","source_language":"en","source_url":"https://github.com/GhostofGoes/getmac","tags":["network","mac-address","hardware","cross-platform"],"install":[{"cmd":"pip install getmac","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"get_mac_address","correct":"from getmac import get_mac_address"}],"quickstart":{"code":"from getmac import get_mac_address\n\n# Get the MAC address of the first available local interface\nmac_address = get_mac_address()\nprint(f\"Local MAC Address: {mac_address}\")\n\n# Optionally, get MAC for a specific interface (e.g., 'eth0' or 'en0')\n# interface_mac = get_mac_address(interface='eth0')\n# if interface_mac:\n#     print(f\"MAC for eth0: {interface_mac}\")\n\n# Optionally, get MAC for a remote IP address (requires ARP access)\n# remote_ip = '192.168.1.1' # Replace with a reachable IP\n# remote_mac = get_mac_address(ip=remote_ip)\n# if remote_mac:\n#     print(f\"MAC for {remote_ip}: {remote_mac}\")","lang":"python","description":"Demonstrates how to retrieve the local machine's MAC address, and optionally, how to fetch the MAC address for a specific interface or a remote IP."},"warnings":[{"fix":"Upgrade to Python 3.7+ or pin `getmac<1.0.0` in your project's dependencies.","message":"Compatibility with Python versions 2.7, 3.4, 3.5, and 3.6 will be completely removed in `getmac` 1.0.0. If your project relies on these older Python environments, you must pin your `getmac` dependency to `<1.0.0` (e.g., `getmac~=0.9.0`) to prevent breakage upon upgrade.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Review the 'docs/rewrite.md' (from the 0.9.0 release) for details on changes and thoroughly test your application after upgrading.","message":"Version 0.9.0 was a 'complete rewrite' of the library. While the public API aimed for backward compatibility, significant internal refactoring occurred. Users upgrading from versions prior to 0.9.0 should conduct thorough testing, as behavioral changes or differences in how MAC addresses are resolved in edge cases might occur.","severity":"gotcha","affected_versions":"<0.9.0"},{"fix":"For critical applications, test `getmac` extensively across target platforms. Utilize `interface` or `ip` parameters to narrow down retrieval scope and implement retry logic or fallback mechanisms.","message":"MAC address retrieval is highly dependent on the operating system, network configuration, and available system utilities. `getmac` has a history of fixing platform-specific issues (e.g., macOS ARP, BusyBox arping, IPv6 handling). Inconsistent or unexpected results may arise on certain OS/network environments; consider specifying `interface` or `ip` for more targeted queries and robust error handling.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-15T00:00:00.000Z","next_check":"2026-07-14T00:00:00.000Z"}