Temperature Code help? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Temperature Code help? (/thread-2762.html) |
Temperature Code help? - 20AJ0931 - Apr-07-2017 Why is this working? - import wmi w = wmi.WMI(namespace="root\OpenHardwareMonitor") temperature_infos = w.Sensor() for sensor in temperature_infos: if sensor.SensorType==u'Temperature': if sensor.Name=='CPU Package': print( sensor.Name ) print( sensor.Value )but this isn't working- import wmi w = wmi.WMI(namespace='root\\wmi') temperature = w.MSAcpi_ThermalZoneTemperature()[0] temperature = int(temperature.CurrentTemperature / 10.0 - 273.15) print( temperature )I am getting this error when I run the second code - During handling of the above exception, another exception occurred: I don't know what this means. I am new to python and I need to find the temperature of my laptop for a project I am working on. I know I am making some mistake but cannot figure what mistake I am making. To all the experienced guys out there, can you help me? Any help would be appreciated.Moderator Larz60+: Added error tags
RE: Temperature Code help? - wavic - Apr-07-2017 Open the Command prompt as administrator and run the script from there RE: Temperature Code help? - snippsat - Apr-08-2017 w = wmi.WMI(namespace='root\\wmi')Change To: w = wmi.WMI(namespace=r'root\wmi', privileges=["Security"])Run code as administrator,testet Win-10 Python 36 okay for me. |