Python 使用SDK在Google Cloud中设置环境变量时出错

Python 使用SDK在Google Cloud中设置环境变量时出错,python,python-3.x,google-cloud-platform,google-cloud-functions,gcloud,Python,Python 3.x,Google Cloud Platform,Google Cloud Functions,Gcloud,我正试图在谷歌云上为我的Django应用程序设置环境变量。 我在SDK上输入了以下内容: gcloud functions deploy env_vars --runtime python37 --set-env-vars SUBSCRIPTION_KEY=1234567890 --trigger-http 返回的错误为: ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: {"error

我正试图在谷歌云上为我的Django应用程序设置环境变量。 我在SDK上输入了以下内容:

gcloud functions deploy env_vars --runtime python37 --set-env-vars SUBSCRIPTION_KEY=1234567890 --trigger-http
返回的错误为:

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: {"error": {"canonicalCode": "INTERNAL", "errorMessage": "`pip_install_from_wheels` had stderr output:\n/opt/python3.7/bin/python3.7: No module named pip\n\nerror: `pip_install_from_wheels` returned code: 1", "errorType": "InternalError", "errorId": "ECB5F712"}}
请帮忙

我的
requirements.txt
文件:

Django==2.2.5
Pillow==6.2.1
azure-cognitiveservices-language-textanalytics==0.2.0
azure-cognitiveservices-nspkg==3.0.1
azure-cognitiveservices-search-newssearch==1.0.0 
azure-cognitiveservices-search-nspkg==3.0.1
azure-common==1.1.23
azure-nspkg==3.0.2
msrest==0.6.10
numpy==1.17.1
oauthlib==3.1.0
pandas==0.24.2
pandas-datareader==0.7.4
pip==19.0.3
requests==2.21.0
setuptools==40.8.0
sqlparse==0.3.0
statistics==1.0.3.5
ta==0.4.5
gunicorn==20.0.4

您的
requirements.txt中有
pip
,可能是因为您执行了类似于
pip-freeze--all>requirements.txt的操作。用于云函数的Python 3.7运行时存在一个错误,将
pip
指定为函数的依赖项会导致此问题


您应该从
requirements.txt
文件中删除
pip
,但也要确保您只指定了实际依赖于您的函数的需求。

您能提供更多信息吗,比如requirements.txt?您的函数名叫env_vars吗?奇怪的在中,错误消息thoughrequirements.txt中似乎缺少一个模块。您是否有可能进入作为脚本用户部署的实例并检查其路径?pip是从Python 3.4开始默认安装的,但它看起来可能不在运行该脚本的用户的路径中?看起来错误在函数代码中,请提供更多详细信息。