0

I reviewed this thread - Accessing CPU temperature in python - and was able to get the script running on my machine, but it seems that it's only running as expected when the OpenHardwareMonitor executable is running.

Is that because I need to run the script in the same directory as where the executable lives? It doesn't seem to make a difference what dir I run the script I run it in so far.

Here's my version of the script:

## Purpose of Script is to use WMI and OpenHardWareMonitor to 
##   get 
## CPU temperatures

## Reference:
## https://stackoverflow.com/questions/3262603/accessing-cpu-
## temperature-in-python/32840852#32840852

## Requirements:
##
## WMI Module - https://pypi.org/project/WMI/
## OpenHardwareMonitor - 
## https://openhardwaremonitor.org/downloads/
## Seems that the OpenHardWareMonitor executable needs to be 
## running 
## for the script to run

## This script uses Py3.10 
## Must run with interpreter 3.10 for module to be recognized 

import wmi
w = wmi.WMI(namespace="root\OpenHardwareMonitor")
temperature_infos = w.Sensor()
for sensor in temperature_infos:
    if sensor.SensorType==u'Temperature':
         print(sensor.Name)
         print(sensor.Value)
    
## Known issues so far
##
## Script doesn't run unless OpenHardWareMonitor executable is    
## running.
xpkiro
  • 1
  • 3
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jan 25 '22 at 05:52

0 Answers0