繁体   English   中英

Python 3(Linux 和 Windows)中的 CPU 温度

[英]CPU Temperature in Python 3 (Linux & Windows)

我正在寻找 Python 3 中的 CPU 温度。可以是不同的库,但我需要一个用于 Linux 和 Windows 的库。

psutil.sensors_temperature 似乎只适用于 Python 2。我找不到任何其他合适的替代品。

您可以使用psutil在 python3 中安装pip 在 Ubuntu 上,您可能需要 psutil 所需的某些psutil文件的python-dev包。 您可能还需要使用pip3而不是pip

Python 3.8.3 (default, May 17 2020, 18:15:42) 
[GCC 10.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil             
>>> psutil.sensors_temperatures()
{'nvme': [shwtemp(label='Composite', current=37.85, high=84.85, critical=84.85), shwtemp(label='Sensor 1', current=37.85, high=65261.85, critical=65261.85), shwtemp(label='Sensor 2', current=43.85, high=65261.85, critical=65261.85)], 'k10temp': [shwtemp(label='Tctl', current=55.0, high=None, critical=None), shwtemp(label='Tdie', current=55.0, high=None, critical=None), shwtemp(label='Tccd1', current=39.5, high=None, critical=None)], 'nct6797': [shwtemp(label='SYSTIN', current=42.0, high=80.0, critical=80.0), shwtemp(label='PCH_CPU_TEMP', current=0.0, high=None, critical=None), shwtemp(label='CPUTIN', current=37.0, high=115.0, critical=115.0), shwtemp(label='AUXTIN0', current=38.5, high=115.0, critical=115.0), shwtemp(label='AUXTIN1', current=-128.0, high=None, critical=None), shwtemp(label='AUXTIN2', current=60.0, high=None, critical=None), shwtemp(label='AUXTIN3', current=-3.0, high=None, critical=None), shwtemp(label='SMBUSMASTER 0', current=55.0, high=None, critical=None), shwtemp(label='PCH_CHIP_CPU_MAX_TEMP', current=0.0, high=None, critical=None), shwtemp(label='PCH_CHIP_TEMP', current=0.0, high=None, critical=None)]}
>>> 

您可以简单地导入它,它应该可以工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM