【问题标题】:Error on setting Environment variables in Google Cloud using the SDK使用 SDK 在 Google Cloud 中设置环境变量时出错
【发布时间】:2020-04-22 02:10:44
【问题描述】:

我正在尝试在 Google Cloud 上为我的 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?
  • 你的函数名是 env_vars 吗?诡异的。似乎您在错误消息中缺少一个模块
  • requirements.txt 添加
  • 您是否有机会进入以脚本用户身份部署的实例并检查其路径? pip 自 Python 3.4 起默认安装,但看起来它可能不在运行该脚本的用户路径中?
  • 函数代码中似乎有错误,请提供更多详细信息。

标签: python python-3.x google-cloud-platform google-cloud-functions gcloud


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2015-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-13
    相关资源
    最近更新 更多