Python Forum

Full Version: Encoding and mac-vendor-lookup library
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi everyone!
I'm pretty new to python, so i want to look-up a mac address using mac-vendor-lookup library.
When i run the script on my laptop (Intel-P 3.7.4) everything works fine, but when i run it with my PC (AMD-P 3.8.1)
It's got error:
Here's the error.

Output:
C:\Users\ADMIN>python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from mac_vendor_lookup import *
>>> a = '18:60:24:aa:dd:bd'
>>> print(MacLookup().lookup(a))
Error:
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mac_vendor_lookup.py", line 84, in lookup return self.loop.run_until_complete(self.async_lookup.lookup(mac)) File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\asyncio\base_events.py", line 612, in run_until_complete return future.result() File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python38-32\lib\site-packages\mac_vendor_lookup.py", line 72, in lookup return self.prefixes[mac[:6]].decode("utf8") KeyError: b'186024' >>>
I Hope you guys can help me out.
Many thanks!
You are getting a key error saying the key "186024" was not found. MacLookup() must create a dictionary and MacLookup().lookup() was unable to find the provided mac address. I peeked at the project description and it doesn't say how it handles not finding the provided mac address. Maybe it throws an exception.

In an interactive python console what do you get when you type:
import 'mac_vendor_lookup'
help('mac_vendor_lookup')

Anther user reported the same error as you when running on windows:

https://github.com/bauerj/mac_vendor_lookup/issues/3

Sounds like MacLookup() creates some kind of database (in an 806KB file) and building the database can be interrupted by doing the lookup(). What happens if you do this:

db = MacLookup()
time.sleep(1)
print(db.lookup(a))