Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the system info with Python?

I need to get the info under what environment the software is running. Does python have a library for this purpose?

I want to know the following info.

  • OS name/version
  • Name of the CPU, clock speed
  • Number of CPU core
  • Size of memory
like image 780
prosseek Avatar asked Jun 23 '10 15:06

prosseek


People also ask

How do I see CPU usage in Python?

Use the os Module to Retrieve Current CPU Usage in Python We can use the cpu_count() function from this module to retrieve the CPU usage. The psutil. getloadavg() function provides the load information about the CPU in the form of a tuple. The result obtained from this function gets updated after every five minutes.

How do I print the computer name in Python?

Use the os. uname() Function to Find the Hostname of a Machine in Python. To use the os. uname() function, the os module needs to be imported to the Python code.


1 Answers

some of these could be obtained from the platform module:

>>> import platform >>> platform.machine() 'x86' >>> platform.version() '5.1.2600' >>> platform.platform() 'Windows-XP-5.1.2600-SP2' >>> platform.uname() ('Windows', 'name', 'XP', '5.1.2600', 'x86', 'x86 Family 6 Model 15 Stepping 6, GenuineIntel') >>> platform.system() 'Windows' >>> platform.processor() 'x86 Family 6 Model 15 Stepping 6, GenuineIntel' 
like image 68
SilentGhost Avatar answered Sep 23 '22 00:09

SilentGhost