簡體   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