Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on running pihealth.py #3

Open
ghost opened this issue Aug 12, 2016 · 8 comments
Open

Error on running pihealth.py #3

ghost opened this issue Aug 12, 2016 · 8 comments

Comments

@ghost
Copy link

ghost commented Aug 12, 2016

Traceback (most recent call last): File "pihealth.py", line 80, in <module> main() File "pihealth.py", line 27, in main cpu_temperature = get_cpu_temperature() File "pihealth.py", line 21, in get_cpu_temperature return float(output[output.index('=') + 1:output.rindex("'")]) ValueError: substring not found

Raspberry Pi B+
Linux 30ir000 4.1.13+ #826 PREEMPT Fri Nov 13 20:13:22 GMT 2015 armv6l GNU/Linux
PRETTY_NAME="Raspbian GNU/Linux 7 (wheezy)"
NAME="Raspbian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=raspbian
ID_LIKE=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

@jrbail01
Copy link
Contributor

When you run the command:

vcgencmd measure_temp

do you get a response?

@ghost
Copy link
Author

ghost commented Aug 13, 2016

VCHI initialization failed

@jrbail01
Copy link
Contributor

Looks like other people have had this issue with vcgencmd in the past (e.g. https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=50262). You can try some of the solutions other people have found or you can simply comment out the python lines that are grabbing CPU temperature (lines 27-32).

@ghost
Copy link
Author

ghost commented Aug 13, 2016

sudo vcgencmd measure_temp gives the correct result. Permissions on /dev/vchiq are correct. I will look for another solution and send feedback.

@jrbail01
Copy link
Contributor

Have you tried running the Python script with sudo?

sudo python pihealth.py

@ghost
Copy link
Author

ghost commented Aug 13, 2016

That’s what i do now and that works. It’s a system that is exposed to the
internet, so having a script running as root is not my preference, but
anyway, now it works.

On Sat, Aug 13, 2016 at 6:18 PM, jrbail01 [email protected] wrote:

Have you tried running the Python script with sudo?

sudo python pihealth.py


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#3 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEqHE9ri4i_JdipwKyJ0a-sVf1ZQsvT0ks5qfe5ygaJpZM4JjLFy
.

@Horcrux82
Copy link

Traceback (most recent call last): File "pihealth.py", line 80, in <module> main() File "pihealth.py", line 27, in main cpu_temperature = get_cpu_temperature() File "pihealth.py", line 21, in get_cpu_temperature return float(output[output.index('=') + 1:output.rindex("'")]) TypeError: Type str doesn't support the buffer API

Error i got when trying to run the pihealth.py file

@Richard238
Copy link

Richard238 commented Nov 6, 2020

vcgencmd measure_temp works OK.
As suggested by @jrbail01 above, the workaround is to comment out the CPU temp lines.
What's the proper fix for this, please, so I get CPU temp on I.S?

Here's a working, proper fix:

Line 21

#    return float(output[output.index('=') + 1:output.rindex("'")])
     return float(output[output.index(ord('=')) + 1:output.rindex(ord("'"))])

Credit to https://forums.pimoroni.com/t/enviro-plus-examples-error/11080/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants