Question

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
Was it helpful?

Solution

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'

OTHER TIPS

The os module has the uname function to get information about the os & version:

>>> import os
>>> os.uname()

For my system, running CentOS 5.4 with 2.6.18 kernel this returns:

('Linux', 'mycomputer.domain.user','2.6.18-92.1.22.el5PAE', '#1 SMP Tue Dec 16 12:36:25 EST 2008', 'i686')

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top