我试图为azure iothub安装python包并使用Ubuntu-14.04连接到它但是出现了一些错误。
这是错误。
(env) pr@pr-ubuntu:~/azure-iot-sdk-python/service/samples$ python iothub_devicetwin_sample.py
Python 2.7.6 (default, Oct 26 2016, 20:30:19)
[GCC 4.8.4]
IoT Hub Service Client for Python
Starting the IoT Hub Service Client DeviceTwin Python sample...
Connection string = HostName=bossatest.azure-devices.net;DeviceId=robot1;SharedAccessKey=aI2/uTjcQxmFv4Ya4TgGUW4tYvkDTjbrGG7cB5ogVfU=
Device ID = robot1
Error: Time:Tue Jun 13 06:38:38 2017 File:/home/prem/azure-iot-sdk-python/c/iothub_service_client/src/iothub_service_client_auth.c Func:IoTHubServiceClientAuth_CreateFromConnectionString Line:83 Couldn't find SharedAccessKeyName in connection string
Traceback (most recent call last):
File "iothub_devicetwin_sample.py", line 66, in <module>
iothub_devicetwin_sample_run()
File "iothub_devicetwin_sample.py", line 36, in iothub_devicetwin_sample_run
print ( "Unexpected error {0}" % iothub_error )
TypeError: not all arguments converted during string formatting
答案 0 :(得分:0)
根据您的错误信息,根据here中的示例源代码,问题是由您使用的缺少SharedAccessKeyName
属性的连接字符串引起的。
在示例源代码中,连接字符串应如下所示。
# String containing Hostname, SharedAccessKeyName & SharedAccessKey in the format: # "HostName=<host_name>;SharedAccessKeyName=<SharedAccessKeyName>;SharedAccessKey=<SharedAccessKey>"