aliyun-openapi-python-sdk icon indicating copy to clipboard operation
aliyun-openapi-python-sdk copied to clipboard

Get error from aliyunsdkiot.request.v20180120 import PubRequest.

Open l1117 opened this issue 7 years ago • 2 comments

FC Invoke Start RequestId: ff3b17d8-a009-8d60-02a6-f1528aada27b 2018-12-29T10:45:52.890Z ff3b17d8-a009-8d60-02a6-f1528aada27b [ERROR] {'stackTrace': ['ImportError: cannot import name PubRequest'], 'errorType': 'ImportError', 'errorMessage': "Unable to import module 'index'"} FC Invoke End RequestId: ff3b17d8-a009-8d60-02a6-f1528aada27b

l1117 avatar Dec 29 '18 10:12 l1117

Thanks for your feedback. It's a very interesting issue, and we are sorry that we can not reproduce it。Maybe you can use according to the following way

from aliyunsdkiot.request.v20180120 import PubRequest

request = PubRequest.PubRequest()
request.set_ProductKey(product-key)
request.set_TopicFullName(topic-full-name)
request.set_MessageContent('hello world')

clt  = client.AcsClient(
    "<access-key-id>",
    "<access-key-secret>",
    "<region-id>"
)
response = clt.do_action_with_exception(request)
print(str(response, encoding='utf-8'))

Suvie277 avatar Jan 02 '19 02:01 Suvie277

@l1117 We consulted FunctionCompute team and they said the reason for your error was: you were trying to call IoT SDK version 7.x.x, but the pre-installed version of IoT SDK was 6.x.x.

Because IoT SDK 7.x.x is not compatible with 6.x.x, to avoid breaking the current users' application, FC chose not to upgrade IoT SDK.

To fix your problem, please download & pack IoT SDK 7.x.x to your lib directory which the FC service will load by default. Hope it helps.

Thank you.

Qingtang-SDK avatar Jan 14 '19 12:01 Qingtang-SDK