Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7493

Troubleshooting • Re Bookworm on Pi 5, no vcgencmd import for python

$
0
0
I saw this python 3 script quoted in a few places as a temperature check for the Pi 5 cpu core but this is the problem, from vcgencmd import Vcgencmd
ModuleNotFoundError: No module named 'vcgencmd'

Here's the script:
import sys
import os
import time
from vcgencmd import Vcgencmd

def main():
start_time = time.time()
fb = open("/home/pi/readings.txt","a+")
fb.write("Elapsed Time (s),Temperature (°C),Clock Speed (MHz),Throttled\n")
vcgm = Vcgencmd()
while True:
temp = vcgm.measure_temp()
clock = int(vcgm.measure_clock('arm')/1000000)
throttled = vcgm.get_throttled()['breakdown']['2']

string = '%.0f,%s,%s,%s\n' % ((time.time() - start_time),temp,clock,throttled)
print(string, end='')
fb.write(string)
time.sleep(1)

if __name__ == '__main__':
main()

Can anyone tell me how to get vcgencmd module for python, I tried pip and this does not work.

sudo pip3 install vcgencmd
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.

If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
I also tried sudo apt install python3-vcgencmd which also did not work.
I do have python3-full installed.

Statistics: Posted by Susan7 — Fri Jan 26, 2024 3:26 am — Replies 1 — Views 82



Viewing all articles
Browse latest Browse all 7493

Trending Articles