mac-vendor-lookup

raw JSON →
0.1.15 verified Fri May 01 auth: no python

Looks up the vendor (manufacturer) for a given MAC address using the IEEE OUI database. Current version is 0.1.15, compatible with Python >=3.5 and <4. Released as needed, with stable API.

pip install mac-vendor-lookup
error 'coroutine' object is not subscriptable
cause Calling lookup() without await returns a coroutine, not the vendor string.
fix
Add 'await' before mac.lookup('00:11:22:33:44:55') and make sure the calling function is async.
error ValueError: Could not determine vendor for 00:11:22:33:44:55
cause MAC address not found in the OUI database, or database not updated.
fix
Call await mac.update_vendors() first (or set a cache) to download the latest IEEE OUI list.
error AttributeError: module 'mac_vendor_lookup' has no attribute 'MacLookup'
cause Importing the top-level module instead of the class.
fix
Use 'from mac_vendor_lookup import MacLookup'.
gotcha The library requires an asynchronous context: lookup is async and must be awaited. Running synchronous code will raise a coroutine TypeError.
fix Use 'await mac.lookup(...)' in an async function, or use 'asyncio.run()' as shown in quickstart.
gotcha The vendor database file is downloaded on first call to update_vendors(). If the download fails or takes long, the call blocks the event loop.
fix Ensure network access on first run, or use a local cache file by setting the 'MAC_VENDOR_CACHE' environment variable (not officially documented). Consider calling update_vendors() during setup.
deprecated The synchronous method 'lookup' used to exist? No, the API has always been async. Some older commits may show sync wrappers, but official releases are async.
fix Always use async/await pattern.

Initialize MacLookup, update the OUI database, and look up a MAC address.

import asyncio
from mac_vendor_lookup import MacLookup

async def main():
    mac = MacLookup()
    await mac.update_vendors()
    vendor = await mac.lookup('00:11:22:33:44:55')
    print(vendor)

asyncio.run(main())