【问题标题】:Google Cloud Function can't install a python packageGoogle Cloud Function 无法安装 python 包
【发布时间】:2020-02-17 19:29:18
【问题描述】:

我最近在https://pypi.org/project/gsuitefy/ 上发布了一个包 我可以在本地安装包而没有错误,但是当我在函数的“requirements.txt”中添加包(gsuitefy)时出现错误:

Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`pip_download_wheels` had stderr output:\n  Could not find a version that satisfies the requirement gsuitefy==1.0.3 (from -r requirements.txt (line 5)) (from versions: )\nNo matching distribution found for gsuitefy==1.0.3 (from -r requirements.txt (line 5))\n\nerror: `pip_download_wheels` returned code: 1", "errorType": "InternalError", "errorId": "84C90901"}}

【问题讨论】:

标签: python google-cloud-platform google-cloud-functions


【解决方案1】:

gsuitefy package 似乎只与 python2 兼容,而不与 python3 兼容。

例如使用python3虚拟环境:

(venv) $ pip --version 来自 /home/[XXXXX]/venv/local/lib/python3.7/site-packages/pip 的 pip 19.3.1(python 3.7) (venv) $ pip install -v gsuitefy 创建临时目录:/tmp/pip-ephem-wheel-cache-8fvgqqfg 创建临时目录:/tmp/pip-req-tracker-itd0y72w 创建需求跟踪器'/tmp/pip-req-tracker-itd0y72w' 创建临时目录:/tmp/pip-install-hlzzykc0 1 个位置可搜索 gsuitefy 的版本: * https://pypi.org/simple/gsuitefy/ 获取页面 https://pypi.org/simple/gsuitefy/ 找到索引网址 https://pypi.org/simple 在缓存中查找“https://pypi.org/simple/gsuitefy/” 请求标头的“max_age”为 0,绕过缓存 启动新的 HTTPS 连接 (1): pypi.org:443 https://pypi.org:443 "GET /simple/gsuitefy/HTTP/1.1" 304 0 分析来自页面 https://pypi.org/simple/gsuitefy/ 的链接 跳过链接:轮子的标签都不匹配:py2-none-any:https://files.pythonhosted.org/packages/42/ae/045782c202c626c3b76489a9a1b0b2bf398a956166fc0870719d653e7536/gsuitefy-1.0.3-py2-none-any.wh l#sha256=44e92f23821eedcdae1f2748b468d1a321541b5ee45c49653adaec079f68369d(来自https://pypi.org/simple/gsuitefy/) 跳过链接:没有一个轮子的标签匹配:py2-none-any:https://files.pythonhosted.org/packages/9d/73/b3b079b9a6cb15c8fb32f950ee504cf0e0af99a8ad11fec636b8aa5a0919/gsuitefy-1.1.0-py2-none-any.wh l#sha256=1307c572a4ba2ce491cc9177d7c288c40f03ee5c051154863d441a5dd54f6300(来自 https://pypi.org/simple/gsuitefy/) 跳过链接:轮子的标签都不匹配:py2-none-any:https://files.pythonhosted.org/packages/a1/15/b126d59768cc0b3ca9e276470f67a602f18767d180771bcbf1e137e17891/gsuitefy-1.1.1-py2-none-any.wh l#sha256=720178a7ac6056d747cfe1c237ff2e9b3f3207268466c83671931a0e1766c985(来自https://pypi.org/simple/gsuitefy/) 跳过链接:轮子的标签都不匹配:py2-none-any:https://files.pythonhosted.org/packages/21/3f/a2546b4ad2599a6af6304a963e4f3c4be9cf9785bab095cf35c161f1d420/gsuitefy-1.1.2-py2-none-any.wh l#sha256=ff23036822e04c4aafa4c271ac4064400e3079b8df6a869d66284d58b9c0aeed(来自 https://pypi.org/simple/gsuitefy/) 没有哈希来检查项目“gsuitefy”的 0 个链接:不丢弃任何候选人 错误:找不到满足 gsuitefy 要求的版本(来自版本:无)

另一方面,这在 python 2 虚拟环境中安装得很好。

cloud functions python runtime 基于(在撰写本文时)Python 3.7.1。您需要创建与 Python 3.7 兼容的软件包版本才能正确安装。

【讨论】:

  • 感谢@robsiemb 它有效。我需要像这样使用“--universal”参数:python setup.py bdist_wheel --universal
  • @MarcosVidolin 除了构建发行版之外,您应该始终发布源代码发行版 (python setup.py sdist),这样可以确保即使构建发行版与给定平台不匹配,您的用户仍然可以安装来源。
猜你喜欢
  • 2019-06-03
  • 1970-01-01
  • 2019-06-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多