Skip to content

all-in-one error #15

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
koaning opened this issue Jul 16, 2019 · 5 comments
Closed

all-in-one error #15

koaning opened this issue Jul 16, 2019 · 5 comments

Comments

@koaning
Copy link

koaning commented Jul 16, 2019

unfortunately there is a new error. when running this from ipython:

In [12]: %run all-in-one.py                                                                                   
all-in-one.py - Displays readings from all of Enviro plus' sensors

Press Ctrl+C to exit!


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/AIY-projects-python/enviroplus-python/examples/all-in-one.py in <module>
    133             variable = "temperature"
    134             unit = "C"
--> 135             cpu_temp = get_cpu_temperature()
    136             # Smooth out with some averaging to decrease jitter
    137             cpu_temps = cpu_temps[1:] + [cpu_temp]

~/AIY-projects-python/enviroplus-python/examples/all-in-one.py in get_cpu_temperature()
     87     process = Popen(['vcgencmd', 'measure_temp'], stdout=PIPE)
     88     output, _error = process.communicate()
---> 89     return float(output[output.index('=') + 1:output.rindex("'")])
     90 
     91 

TypeError: a bytes-like object is required, not 'str'
@koaning
Copy link
Author

koaning commented Jul 16, 2019

version information:

In [15]: sys.version                                                                                          
Out[15]: '3.5.3 (default, Jan 19 2017, 14:11:04) \n[GCC 6.3.0 20170124]'

@makeupsomething
Copy link
Contributor

I was able to fix this by converting the output to a string

decoded_output = output.decode("utf-8")
return float(decoded_output[decoded_output.index('=') + 1:decoded_output.rindex("'")])

@cipy
Copy link
Contributor

cipy commented Aug 2, 2019

@koaning your iPython is version 3.5.3

and Python3 doesn't seem to be supported yet, see issue #21

meaning some other parts of the code could blow up if Python3 support was not tested

@kflmiami420
Copy link

Please can I get an estimated time this fix will be applied to the all_in_one_no_pm.py script so it can be run in python3 today is 08-17-2019

@cipy
Copy link
Contributor

cipy commented Aug 17, 2019

@kflmiami420 well, the solution is to append , universal_newlines=True to all Popen calls

see #24

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

5 participants