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.
pip install getmacVerified import paths — ran on the pinned version, not inferred.
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.
Upgrade to Python 3.7+ or pin `getmac<1.0.0` in your project's dependencies.
Review the 'docs/rewrite.md' (from the 0.9.0 release) for details on changes and thoroughly test your application after upgrading.
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.
Install the library using pip: `pip install getmac` or `python -m pip install getmac`. If multiple Python versions are present, ensure you use the correct pip (e.g., `pip3 install getmac`).
Ensure the target host is reachable and on the local network. Try specifying a different interface, IP, or hostname. For remote hosts, ensure `network_request=True` is set (which is the default, but can be explicitly enabled). Check for relevant permissions if running on Linux/macOS. For persistent issues on Windows, ensure WMI is functioning correctly. If on Linux/WSL, be aware that getting the MAC of a local interface IP might not work.
Ensure Windows Management Instrumentation (WMI) service is running and accessible. Check system permissions for the user running the command or Python script. Running the command prompt or script as an administrator might resolve permission-related `Invalid class` errors. Also, ensure the Windows installation itself is not corrupted.
Replace `get_mac(...)` with `get_mac_address(...)`. For example, instead of `from getmac import get_mac; mac = get_mac()`, use `from getmac import get_mac_address; mac = get_mac_address()`.
No dependency data recorded yet.