Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a unique computer ID in Python on windows and linux

I'd like to get an id unique to a computer with Python on Windows and Linux. It could be the CPU ID, the motherboard serial, ... or anything else.

I looked at several modules (pycpuid, psi, ...) without luck.

Any idea on how to do that?

like image 275
darkpotpot Avatar asked Mar 17 '10 09:03

darkpotpot


People also ask

How do I find the unique machine ID in Python?

If you want a guaranteed-unique installation ID, try generating a random UUID when the user runs your app the 1st time (via uuid lib), and save that UUID to config. But that fails if the user copies/moves their installation and gives their per-installation UUID to another computer too.

What is unique ID in Linux?

UUID is a unique identifier used in partitions to uniquely identify partitions in Linux operating systems. UUID is a property of the disk partition itself. So, if you install the hard drive containing the partitions on another Linux computer, the partitions will have the same UUID as before. So, that's a good thing.


1 Answers

There seems to be no direct "python" way of doing this. On modern PC hardware, there usually is an UUID stored in the BIOS - on Linux there is a command line utility dmidecode that can read this; example from my desktop:

System Information         Manufacturer: Dell Inc.         Product Name: OptiPlex 755                          Version: Not Specified         Serial Number: 5Y8YF3J         UUID: 44454C4C-5900-1038-8059-B5C04F46334A         Wake-up Type: Power Switch         SKU Number: Not Specified         Family: Not Specified 

The problem with MAC addresses is that usually you can easily change them programmatically (at least if you run the OS in a VM)

On Windows, you can use this C API

like image 132
Kimvais Avatar answered Oct 21 '22 20:10

Kimvais