【问题标题】:Google Cloud Function in Python gives an error on deployingPython中的Google Cloud Function在部署时出错
【发布时间】:2020-03-01 14:38:55
【问题描述】:

我正在尝试将 Google Cloud Functions 配置为在触发该功能时下订单。 我在requirements.txt 文件中提到了kiteconnect 但是该功能没有被部署。引发错误“未知资源类型”。

完整的错误消息:

Deployment failure: Build failed: {"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "`pip_download_wheels` had stderr output:\nCommand \"python setup.py egg_info\" failed with error code 1 in /tmp/pip-wheel-97dghcl9/logging/\n\nerror: `pip_download_wheels` returned code: 1", "errorType": "InternalError", "errorId": "67DBDBF3"}}

有没有人有使用云功能在 zerodah 下交易订单的经验?

以下是我尝试过的功能:

import logging
from kiteconnect import KiteConnect

logging.basicConfig(level=logging.DEBUG)

kite = KiteConnect(api_key="xxxxxxxxxxxxxxxxxxxxxxxx")

# Redirect the user to the login url obtained
# from kite.login_url(), and receive the request_token
# from the registered redirect url after the login flow.
# Once you have the request_token, obtain the access_token
# as follows.

data = kite.generate_session("xxxxxxxxxxxxxxxxxxxxxxxxx", secret="xxxxxxxxxxxxxxxxxxxxxxxxxx")
kite.set_access_token(data["xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"])

# Place an order
def orderPlace():
    order_id = kite.place_order(
        variety=kite.VARIETY_REGULAR,
        exchange=kite.EXCHANGE_NSE,
        tradingsymbol="INFY",
        transaction_type=kite.TRANSACTION_TYPE_BUY,
        quantity=1,
        product=kite.PRODUCT_CNC,
        order_type=kite.ORDER_TYPE_MARKET
    )

    logging.info("Order placed. ID is: {}".format(order_id))
except Exception as e:
    logging.info("Order placement failed: {}".format(e.message))

requirements.txt 文件内容:

# Function dependencies, for example:
# package>=version
kiteconnect

【问题讨论】:

  • 总是将完整的错误消息(从单词“Traceback”开始)作为文本(不是屏幕截图)放在有问题的(不是评论)中。还有其他有用的信息。
  • 谢谢。但是 Traceback 没有错误消息。我可以在日志中看到以下内容:2019-11-05 12:40:02.628 IST Cloud Functions UpdateFunction us-central:pl_ord xxxxxxxxxxxxxxx@gmail.com INVALID_ARGUMENT
  • 还发现:部署失败:构建失败:{"error": {"canonicalCode": "INVALID_ARGUMENT", "errorMessage": "pip_download_wheels had stderr output:\nCommand \"python setup .py egg_info\" 失败,错误代码 1 在 /tmp/pip-wheel-97dghcl9/logging/\n\nerror: pip_download_wheels 返回代码: 1", "errorType": "InternalError", "errorId": "67DBDBF3 "}}
  • 所有有问题的日志消息 - 它们将更具可读性。其他人也会看到他们。他们可能会跳过 cmets。
  • 请添加您的 requirements.txt 文件的内容。你在本地测试过这段代码吗?

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


【解决方案1】:

错误表明您的依赖项之一是可卸载的。

看起来kiteconnect 依赖项目前与 Python 3.7 不兼容,这是 Cloud Functions 在其运行时使用的 Python 版本:https://github.com/zerodhatech/pykiteconnect/issues/55

您需要等到维护人员发布与 Python 3.7 兼容的新版本。

【讨论】:

  • 感谢您的回答。看起来这就是问题所在。让我与维护人员确认这一点,然后回到这里。
猜你喜欢
  • 2021-10-17
  • 1970-01-01
  • 2020-04-29
  • 1970-01-01
  • 2019-08-22
  • 2019-12-30
  • 2017-08-04
  • 2021-07-29
  • 2023-03-13
相关资源
最近更新 更多