我正在开发一个项目,我想在webapp2 python中使用firebase。我在项目的根目录中创建了lib文件夹,以便使用第三方库。然后我导入了firebase管理员,并在导入时给出以下错误。请帮助我,我在做错误的地方,谢谢
进口:
Traceback (most recent call last):
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "C:\Program Files (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "D:\Work\Bolt Reactor\Final Website Production\kompassera\Routes.py", line 5, in <module>
from controllers import Home, Signup, Login, Profile, Listing, Classroom, Search, Enrollment, Firebase
File "D:\Work\Bolt Reactor\Final Website Production\kompassera\controllers\Signup.py", line 5, in <module>
import firebase_admin
File "D:\Work\Bolt Reactor\Final Website Production\kompassera\lib\firebase_admin\__init__.py", line 22, in <module>
from firebase_admin import credentials
File "D:\Work\Bolt Reactor\Final Website Production\kompassera\lib\firebase_admin\credentials.py", line 20, in <module>
import google.auth
ImportError: No module named auth
日志:
split
答案 0 :(得分:0)
解释
import google.auth.transport.requests
以上行将在每台机器上的pythons默认目录中查找Google软件包,这种行为可能会有所不同,具体取决于我要查找已安装软件包的位置。
解决方案: 在你的项目的根目录下创建一个lib目录并将google包放在这个lib目录中,然后在这个lib文件夹中添加____inti____.py并修改你的导入
import lib.firebase_admin
import lib.google.auth.transport.requests
import lib.google.oauth2.id_token
from lib.firebase_admin import auth
from lib.firebase_admin import credentials