我想将google.cloud.storage依赖项添加到我的项目中,所以我尝试使用
安装此依赖项 pip install --upgrade google-cloud-storage
使用dev_appserver再次运行我的应用程序,它向我显示我的gcloud组件需要更新。好的,gcloud components update
在我的src/__init__.py
文件中,我得到的代码告诉gcloud在哪个文件夹中查找依赖项,如下所示:
from google.appengine.ext import vendor
vendor.add('src/libs')
除了我收到错误ImportError: No module named google.oauth2
PS:我的应用正在使用OAuth2来保护对API的访问。在我进行组件更新之前它工作正常,现在即使我回滚代码,删除libs文件夹并再次安装依赖项,我仍然得到No模块错误,似乎dev_appserver没有在libs中寻找那个依赖项文件夹!
以下是gcloud --version
:
Google Cloud SDK 188.0.1
app-engine-python 1.9.66
app-engine-python-extras 1.9.63
bq 2.0.28
core 2018.02.08
gsutil 4.28
这是追溯:
Traceback (most recent call last):
File "/home/login/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/login/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/login/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 96, in LoadObject
__import__(cumulative_path)
File "/home/headless/Documents/Projects/meterFleet/app-backend/src/main.py", line 5, in <module>
from src.app.user.api import UserApi
File "/home/headless/Documents/Projects/meterFleet/app-backend/src/app/user/api.py", line 7, in <module>
from src.googleapis.iam import getIamPolicy, addIapUser, deleteIapUser
File "/home/headless/Documents/Projects/meterFleet/app-backend/src/googleapis/iam.py", line 5, in <module>
from src.common.authentication import OAuth
File "/home/headless/Documents/Projects/meterFleet/app-backend/src/common/authentication.py", line 3, in <module>
from google.oauth2 import service_account
File "/home/login/google-cloud-sdk/platform/google_appengine/google/appengine/tools/devappserver2/python/runtime/sandbox.py", line 1147, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named google.oauth2
答案 0 :(得分:4)
问题来自于安装在项目文件夹(在location | day_of_drive | day_of_reservation | number_of_bookings
-------------------------------------------------------------------
foo | 01-01-2015 | 24-12-2014 | 1
foo | 01-01-2015 | 25-12-2014 | 0
foo | 01-01-2015 | 26-12-2014 | 1
foo | 01-01-2015 | 27-12-2014 | 0
foo | 01-01-2015 | 28-12-2014 | 0
foo | 01-01-2015 | 29-12-2014 | 3
foo | 01-01-2015 | 30-12-2014 | 2
foo | 01-01-2015 | 31-12-2014 | 1
foo | 02-01-2015 | 29-12-2014 | 2
foo | 02-01-2015 | 30-12-2014 | 0
foo | 02-01-2015 | 31-12-2014 | 1
foo | 02-01-2015 | 01-01-2015 | 1
bar | 25-06-2016 | 03-07-2016 | 1
bar | 25-06-2016 | 04-07-2016 | 0
.
.
.
文件夹中)和python本地libs文件夹(/usr/local/python2.7/dist-packages)中的依赖项。我从python libs文件夹中删除了google库,它现在又重新运行了!
答案 1 :(得分:3)
我有这个问题了。我从本地计算机上卸载了所有Google软件包,删除了我的GAE app文件夹中的lib文件夹,再次创建它然后执行:
pip install -t lib google-auth google-auth-httplib2 google-api-python-client --upgrade
那应该解决你的问题。
答案 2 :(得分:3)
只需升级一些python软件包即可解决我的问题:
pip install --upgrade google-auth google-auth-httplib2 google-api-python-client
答案 3 :(得分:0)
我决定使用pipenv解决此问题。
pip3 install pipenv
pipenv install
pipenv shell
然后安装所需的库。
答案 4 :(得分:0)
万一以上都不适合您-我是hiranya911在GitHub上找到this answer的。它完美地解决了我的问题。