KSJ*_*ain 7 python python-3.x raspberry-pi firebase
我正在尝试按照在Raspberry Pi 2 B +上运行的py代码中使用Firebase的说明进行操作.在python 3上运行时,会发生不好的事情.
我在我的脚本中包含了pyrebase,但是当我使用python3运行它时,我得到了以下内容(请参阅下面的内容).我一直在研究各种其他语言,但我选择了python和Raspberry Pi来实现我想到的项目.
这篇文章将包含我运行代码时获得的代码和终端输出
#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)
Run Code Online (Sandbox Code Playgroud)
pi@raspberrypi:~/Desktop/LearnPython $ sudo python3 IoTLED.py
Run Code Online (Sandbox Code Playgroud)
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'
Run Code Online (Sandbox Code Playgroud)
我怀疑opentype库丢失了.
我现在真的真的被困在这一天超过一天了.我需要帮助.非常感谢你,非常感谢你的帮助.
Cap*_*pet 31
我有类似的问题,这为我解决了这个问题:
pip install --upgrade google-auth-oauthlib
google-auth-oauthlib在我的设置中,依赖关系已经过时了.requirements.txt(https://github.com/google/aiyprojects-raspbian/blob/voicekit/requirements.txt)中的版本为0.1.0.我正在使用语音套件,但同样适用于您的设置.
有关更多详细信息,请参阅此问题:ImportError:无法在新安装中导入名称"opentype"
另请参阅覆盆子pi论坛:https://www.raspberrypi.org/forums/viewtopic.php?f = 114&t = 198933&p = 1241439#p1241439
| 归档时间: |
|
| 查看次数: |
13816 次 |
| 最近记录: |