【发布时间】:2018-12-03 00:29:16
【问题描述】:
我正在尝试将 google OAuth 用于我的网络应用程序。为此,我在我的 venv 和 Docker 构建期间(来自 requirements.txt)安装了包 google-api-python-client 和 google-auth。尽管如此,当我运行我的应用程序时,它找不到请求模块,抱怨:
flask.cli.NoAppException: While importing "debateit", an ImportError was raised:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/site-packages/google/auth/transport/requests.py", line 23, in <module>
import requests
ImportError: No module named 'requests'
导入如下:
from google.auth.transport import requests
并且使用如下:
idinfo = id_token.verify_oauth2_token(token, requests.Request(), app.config["GOOGLE_LOGIN_CLIENT_ID"])
id_token.verify_oauth2_token 等其他导入工作正常。
我检查了我的 docker build,它说我正确地包含了 google-auth:
Installing collected packages: ... google-auth, httplib2, google-auth-httplib2, google-api-python-client
Successfully installed ... google-api-python-client-1.7.3 google-auth-1.5.0 google-auth-httplib2-0.0.3 httplib2-0.11.3 ...
当我查看 venv 时,我可以清楚地看到 google.auth.transport.requests 模块,它只是在应用程序本身中不起作用。
我错过了什么?什么可能导致找不到此模块?
【问题讨论】:
标签: python docker google-authentication