Azure / azure-iot-sdk-python

A Python SDK for connecting devices to Microsoft Azure IoT services
MIT License
422 stars 375 forks source link

Missing azure.iot.device.ProvisioningSession import in 3.0.0b2 #1152

Closed Gamecock closed 1 year ago

Gamecock commented 1 year ago

Context

Description of the issue

attmpting to run sample code, unable toimport Provisioning Session

$ py provisioning_symmetric_key.py Traceback (most recent call last): File "C:\Projects\Azure\azure-iot-sdk-python\samples\provisioning_symmetric_key.py", line 3, in from azure.iot.device import ( ImportError: cannot import name 'ProvisioningSession' from 'azure.iot.device' (C:\Projects\Azure\azure-iot-sdk-python\samples.venv\Lib\site-packages\azure\iot\device__init__.py)

Code sample exhibiting the issue

$ py Python 3.11.1 (tags/v3.11.1:a7a450f, Dec 6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

from azure.iot.device import ProvissioningSession Traceback (most recent call last): File "", line 1, in ImportError: cannot import name 'ProvissioningSession' from 'azure.iot.device' (C:\Projects\Azure\azure-iot-sdk-python\samples.venv\Lib\site-packages\azure\iot\device__init__.py)

Console log of the issue

$ ls .venv/Lib/site-packages/azure/iot/device/ init.py connection_string.py edge_hsm.py iothub_http_client.py models.py mqtt_topic_provisioning.py signing_mechanism.py pycache/ constant.py http_path_iothub.py iothub_mqtt_client.py mqtt_client.py request_response.py user_agent.py config.py custom_typing.py iot_exceptions.py iothub_session.py mqtt_topic_iothub.py sastoken.py (.venv) FinchMik Consider setting the DEBUG environment variable to '*'. This will produce a much more verbose output that will help debugging Don't forget to remove any connection string information!

Gamecock commented 1 year ago

I changed the import order

`from azure.iot.device import (

MQTTConnectionDroppedError,
MQTTConnectionFailedError,
ProvisioningSession,

)

the error changed, issue is with the package and not specific Module `$ py samples/provisioning_symmetric_key.py Traceback (most recent call last): File "C:\Projects\Azure\azure-iot-sdk-python\samples\provisioning_symmetric_key.py", line 3, in <module> from azure.iot.device import ( ImportError: cannot import name 'MQTTConnectionDroppedError' from 'azure.iot.device' (C:\Projects\Azure\azure-iot-sdk-python\.venv\Lib\site-packages\azure\iot\device\__init__.py) (.venv)

cartertinney commented 1 year ago

3.0.0.b2 is not yet an official release, and its status is currently somewhat in flux.

I would recommend using the latest version of 2.x instead (2.12.0). Our apologies on the unclear nature of the messaging on this issue.