简体   繁体   中英

Google Cloud Function in Python gives an error on deploying

I am trying to configure Google Cloud Functions to place an order when the function is triggered. I have mentioned kiteconnect in the requirements.txt file But the function doesn't get deployed. throws an error "Unknown resource type".

FULL ERROR MESSAGE:

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"}}

Does anyone have any experience dealing with cloud functions to place a trading order on zerodah?

Following is the function that i have tried:

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))

Content of requirements.txt file:

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

The error indicates that one of your dependencies is uninstallable.

It looks like the kiteconnect dependency is currently incompatible with Python 3.7, which is the Python version Cloud Functions uses in it's runtime: https://github.com/zerodhatech/pykiteconnect/issues/55

You'll need to wait until the maintainers release a new version that is compatible with Python 3.7.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM