Import Error: Cannot import name 'opentype'

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 Libraries
import RPi.GPIO as GPIO
import time
import pyrebase
import os

#Firebase Configuration
config = {
          "apiKey": "apiKey",
          "authDomain": "rpitest-xxxxx.firebaseapp.com",
          "databaseURL": "rpitest-xxxxx.firebaseio.com",
          "storageBucket": "rpitest-xxxxx.appspot.com"
}

firebase = pyrebase.initialize_app(config)

#GPIO Setup
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(22, GPIO.OUT)

#Firebase Database Intialization
db = firebase.database()

#While loop to run until user kills program
while(True):
    #Get value of LED 
    led = db.child("led").get()

    #Sort through children of LED(we only have one)
    for user in led.each():
    #Check value of child(which is 'state')
      if(user.val() == "OFF"):
          #If value is off, turn LED off
          GPIO.output(22, False)
      else:
          #If value is not off(implies it on), turn LED on
          GPIO.output(22, True)

      #0.1 Second Delay
      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.

+4
2

. .

pip install --upgrade pyasn1-modules
+1

Source: https://habr.com/ru/post/1690152/


All Articles