我一直在追踪; https://www.youtube.com/watch?v=yylnC3dr_no
firebase团队关于将python与firebase一起使用的官方教程。我遵循了每个步骤,但是当我运行代码时,它给了我;
Traceback (most recent call last):
File "<ipython-input-12-ca014407308a>", line 1, in <module>
runfile('/home/d7v7loper/Desktop/Firebase/test.py', wdir='/home/d7v7loper/Desktop/Firebase')
File "/usr/lib/python2.7/dist-packages/spyder/utils/site/sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "/usr/lib/python2.7/dist-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/d7v7loper/Desktop/Firebase/test.py", line 1, in <module>
import firebase_admin
File "/home/d7v7loper/.local/lib/python3.6/site-packages/firebase_admin/__init__.py", line 23, in <module>
from firebase_admin import credentials
File "/home/d7v7loper/.local/lib/python3.6/site-packages/firebase_admin/credentials.py", line 21, in <module>
from google.auth.transport import requests
File "/home/d7v7loper/.local/lib/python3.6/site-packages/google/auth/transport/requests.py", line 31, in <module>
caught_exc,
File "<string>", line 3, in raise_from
ImportError: The requests library is not installed, please install the requests package to use the requests transport.
我安装了请求库并尝试了Can Python Requests library be used on Google App Engine?解决方案,但是没有用。
import firebase_admin
from firebase_admin import credentials, firestore
cred = credentials.Certificate('./ServiceAccountKey.json')
default_app = firebase_admin.initialize_app(cred)
db = firestore.client()
response = getQuote()
quote = response.body['quote']
author = response.body['author']
更新 我通过;
重新安装了请求库 sudo pip3 uninstall requests
sudo pip3 uninstall urllib3
sudo pip3 install requests
现在我明白了
回溯(最近通话最近一次):
File "<ipython-input-23-ca014407308a>", line 1, in <module>
runfile('/home/d7v7loper/Desktop/Firebase/test.py', wdir='/home/d7v7loper/Desktop/Firebase')
File "/usr/lib/python2.7/dist-packages/spyder/utils/site/sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "/usr/lib/python2.7/dist-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/d7v7loper/Desktop/Firebase/test.py", line 10, in <module>
response = getQuote()
NameError: name 'getQuote' is not defined