Get error from aliyunsdkiot.request.v20180120 import PubRequest.
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
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'))
@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.