Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
725 views
in Technique[技术] by (71.8m points)

python - Import error: cannot import name 'opentype'

I'm trying to follow the instructions for utilizing Firebase in my py code running on Raspberry Pi 2 B+. While running on python 3, bad stuff happens.

I have included the pyrebase in my script but when I run it using python3 I get following instead (see below please). I have been working on various other languages but I just picked python and Raspberry Pi for a project that I had in mind.

This post will have both my code and the terminal output that I get when I run the code

My Code:

#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's on), turn LED on
          GPIO.output(22, True)

      #0.1 Second Delay
      time.sleep(0.1) 

The Command:

    pi@raspberrypi:~/Desktop/LearnPython $ sudo python3 IoTLED.py

The 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 Remarks:

I am really really really stuck at this point for more than a day now. I need help. Thank you so much and I really appreciate your help.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...