Import error: cannot import name 'opentype'
Ich versuche, Folgen Sie den Anweisungen für die Nutzung von FB in meinem py-code läuft auf Raspberry Pi 2 B+. Beim laufen auf python 3, schlechte Sachen passiert.
Ich habe die pyrebase in meinem script aber wenn ich es mit Python ist3 bekomme ich folgenden statt (siehe bitte unten). Ich habe auf verschiedenen anderen Sprachen, aber ich nahm nur python und Raspberry Pi für ein Projekt das ich im Kopf hatte.
Dieser Beitrag wird sowohl mein code und die Ausgabe im terminal, die ich bekomme, wenn ich den code ausführen
Mein 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)
Den Befehl:
pi@raspberrypi:~/Desktop/LearnPython $ sudo python3 IoTLED.py
Der Ausgabe:
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'
Mein Verdacht:
Ich vermute, dass die opentype-Bibliothek fehlt.
Ende Bemerkungen:
Ich bin wirklich wirklich wirklich stecken an dieser Stelle für mehr als einen Tag jetzt. Ich brauche Hilfe. Danke so viel, und ich wirklich zu schätzen Ihre Hilfe.
pip install --upgrade Pyrebase
. Sie können brechen, andere Dinge jedoch so vorsichtig sein.Danke für die schnelle Antwort. Ich habe Folgendes getan. Ich weiß nicht, ob die Aktualisierung der pyrebase helfen werden. Weil ich gerade installiert die pyrebase gestern.**Mein Heilmittel**
$ sudo apt-get update
$ sudo apt-get dist-upgrade
$ pip install pyasn1 pyasn1-modules
$ sudo apt-get --reinstall install python-pyasn1 python-pyasn1-modules
$ sudo pip install pyrebase
könnte eine schlechte Implementierung, versuchen wir eine manuelle version-Kompatibilitäts-check: welche zahlen haben Sie, wenn die Ausführung
pip list freeze | grep -E "(pyrebase|oauth2client|pyasn1)
InformationsquelleAutor KSJain | 2017-12-01
Du musst angemeldet sein, um einen Kommentar abzugeben.
Ich hatte ein ähnliches problem, und dieses Problem behoben es für mich:
pip install --upgrade google-auth-oauthlib
Sieht es aus wie die
google-auth-oauthlib
Abhängigkeit war veraltet in meinem setup. Die version in der requirements.txt (https://github.com/google/aiyprojects-raspbian/blob/voicekit/requirements.txt) war 0.1.0. Ich war mit dem Sprach-kit, aber das gleiche könnte gelten, eingerichtet.Für weitere details siehe diese Frage: ImportError: cannot import name 'opentype' auf neue installation
Sehen das auch auf dem raspberry pi forum: https://www.raspberrypi.org/forums/viewtopic.php?f=114&t=198933&p=1241439#p1241439
Ja, ich denke schon. Ich angemeldet haben ein Problem hier: github.com/google/aiyprojects-raspbian/issues/196
Ja! Das ist die Lösung. Danke 🙂
Funcionó al primer intento. Gracias.
InformationsquelleAutor Captain Whippet
Können Sie versuchen, diese auch. Es funktionierte für mich.
InformationsquelleAutor alan