I am trying to follow the instructions for using Firebase in my py code running on a Raspberry Pi 2 B +. While working on python 3, bad things happen.
I have included pyrebase in my script, but when I run it with python3, I get the following (see below, please). I worked in different languages, but I just chose python and Raspberry Pi for the project that I had in mind.
This message will have both my code and the terminal output that I get when I run the code
My code is:
import RPi.GPIO as GPIO
import time
import pyrebase
import os
config = {
"apiKey": "apiKey",
"authDomain": "rpitest-xxxxx.firebaseapp.com",
"databaseURL": "rpitest-xxxxx.firebaseio.com",
"storageBucket": "rpitest-xxxxx.appspot.com"
}
firebase = pyrebase.initialize_app(config)
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(22, GPIO.OUT)
db = firebase.database()
while(True):
led = db.child("led").get()
for user in led.each():
if(user.val() == "OFF"):
GPIO.output(22, False)
else:
GPIO.output(22, True)
time.sleep(0.1)
Team:
pi@raspberrypi:~/Desktop/LearnPython $ sudo python3 IoTLED.py
Output:
pi@raspberrypi:~/Desktop/LearnPython $ sudo python3 IoTLED.py
Traceback (most recent call last):
File "IoTLED.py", line 4, in <module>
import pyrebase
File "/usr/local/lib/python3.5/distpackages/pyrebase/__init__.py", line 1, in <module>
from .pyrebase import initialize_app
File "/usr/local/lib/python3.5/distpackages/pyrebase/pyrebase.py", line 17, in <module>
from oauth2client.service_account import ServiceAccountCredentials
File "/usr/local/lib/python3.5/dist-packages/oauth2client/service_account.py", line 26, in <module>
from oauth2client import crypt
File "/usr/local/lib/python3.5/dist-packages/oauth2client/crypt.py", line 23, in <module>
from oauth2client import _pure_python_crypt
File "/usr/local/lib/python3.5/dist-packages/oauth2client/_pure_python_crypt.py", line 24, in <module>
from pyasn1_modules.rfc2459 import Certificate
File "/usr/local/lib/python3.5/dist-packages/pyasn1_modules/rfc2459.py", line 20, in <module>
from pyasn1.type import opentype
ImportError: cannot import name 'opentype'
My suspicions:
I suspect the opentype library is missing.
End Notes:
I really really really got stuck in this place for more than a day. I need help. Thank you so much and I really appreciate your help.