我最近尝试开始使用Pyrebase,在安装Python 2.7.13并安装Pyrebase之后,模块http_client丢失,因此无法导入HTTPConnection。我尝试卸载pyrebase并重新安装它,看看这次是否会包含所有模块但我仍然得到相同的导入错误,声明模块http_client是不存在的。有任何想法吗?
以下是代码:
import pyrebase
config = {
"apiKey": "AIzaSyBYJ9WC68XJg6jGwAGwwxT3wcvGAti4FOg",
"authDomain": "app-2-b1b3e.firebaseapp.com",
"databaseURL": "https://app-2-b1b3e.firebaseio.com/",
"storageBucket": "app-2-b1b3e.appspot.com"
}
fb = pyrebase.initialize_app(config)
firebase = fb.database()
def dataSentTest():
data = {"name": "Mortimer 'Morty' Smith"}
firebase.child("users").child("Morty").set(data)
dataSentTest()
以下是错误消息:
Traceback (most recent call last):
File "/Users/sam/Desktop/Selfie Dash/DataListener.py", line 1, in <module>
import pyrebase
File "/Library/Python/2.7/site-packages/pyrebase/__init__.py", line 1, in <module>
from .pyrebase import initialize_app
File "/Library/Python/2.7/site-packages/pyrebase/pyrebase.py", line 18, in <module>
from gcloud import storage
File "/Library/Python/2.7/site-packages/gcloud/storage/__init__.py", line 43, in <module>
from gcloud.storage.blob import Blob
File "/Library/Python/2.7/site-packages/gcloud/storage/blob.py", line 30, in <module>
from gcloud._helpers import _rfc3339_to_datetime
File "/Library/Python/2.7/site-packages/gcloud/_helpers.py", line 30, in <module>
from six.moves.http_client import HTTPConnection
ImportError: No module named http_client
[Finished in 0.5s with exit code 1]
谢谢!
答案 0 :(得分:0)
这是pytrebase requirements.txt文件
requests==2.11.1
gcloud==0.17.0
oauth2client==3.0.0
requests-toolbelt==0.7.0
python-jwt==2.0.1
pycrypto==2.6.1
我建议您安装这些依赖项,命令:
pip install -r requirements.txt