Skip to content

python3 not supported yet #21

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

Closed
cipy opened this issue Aug 2, 2019 · 1 comment · Fixed by #24
Closed

python3 not supported yet #21

cipy opened this issue Aug 2, 2019 · 1 comment · Fixed by #24

Comments

@cipy
Copy link
Contributor

cipy commented Aug 2, 2019

$ python3 enviroplus-python/examples/all-in-one.py

Displays readings from all of Enviro plus' sensors

Press Ctrl+C to exit!

Traceback (most recent call last):
File "enviroplus-python/examples/all-in-one.py", line 143, in
cpu_temp = get_cpu_temperature()
File "enviroplus-python/examples/all-in-one.py", line 96, in get_cpu_temperature
return float(output[output.index('=') + 1:output.rindex("'")])
TypeError: argument should be integer or bytes-like object, not 'str'

@takkaria
Copy link

takkaria commented Aug 3, 2019

The fix for this with python3 is to add an extra output.decode() line in before the return:

def get_cpu_temperature():
    process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE)
    output, _error = process.communicate()
    output = output.decode()
    return float(output[output.index('=') + 1:output.rindex("'")])

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

Successfully merging a pull request may close this issue.

2 participants