首页 > 解决方案 > ModuleNotFoundError:没有名为“azure”的模块

问题描述

我正在尝试在我的 Windows 开发机器上运行示例代码。当我尝试运行simple_send_message.py时,我收到以下错误消息

Traceback (most recent call last):
  File "msg.py", line 3, in <module>
    from azure.iot.device.aio import IoTHubDeviceClient
ModuleNotFoundError: No module named 'azure'

开发环境详细信息

    PS C:\data\code\youtube\iothub\python-send-message> py --version
    Python 3.8.5

    PS C:\data\code\youtube\iothub\python-send-message>pip install azure-iot-device
    Requirement already satisfied: azure-iot-device in c:\users\heman\appdata\local\programs\python\python37-32\lib\site-packages (2.1.4)
    Requirement already satisfied: PySocks in c:\users\heman\appdata\local\programs\python\python37-32\lib\site-packages (from azure-iot-device) (1.7.1)
    Requirement already satisfied: six<2.0.0,>=1.12.0 in c:\users\heman\appdata\local\programs\python\python37-32\lib\site-packages (from azure-iot-device) (1.15.0)
    Requirement already satisfied: paho-mqtt<2.0.0,>=1.4.0 in c:\users\heman\appdata\local\programs\python\python37-32\lib\site-packages (from azure-iot-device) (1.5.0)
    Requirement already satisfied: requests-unixsocket<1.0.0,>=0.1.5 in c:\users\heman\appdata\local\programs\python\python37-32\lib\site-packages (from azure-iot-device) (0.2.0)
    Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>1.21.1; python_version != "3.4" in c:\users\heman\appdata\roaming\python\python37\site-packages (from azure-iot-device) (1.24.2)
    Requirement already satisfied: requests<3.0.0,>=2.20.0 in c:\users\heman\appdata\roaming\python\python37\site-packages (from azure-iot-device) (2.21.0)
    Requirement already satisfied: janus==0.4.0; python_version >= "3.5" in c:\users\heman\appdata\local\programs\python\python37-32\lib\site-packages (from azure-iot-device) (0.4.0)
    Requirement already satisfied: certifi>=2017.4.17 in c:\users\heman\appdata\roaming\python\python37\site-packages (from requests<3.0.0,>=2.20.0->azure-iot-device) (2019.3.9)
    Requirement already satisfied: idna<2.9,>=2.5 in c:\users\heman\appdata\roaming\python\python37\site-packages (from requests<3.0.0,>=2.20.0->azure-iot-device) (2.8)
    Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\heman\appdata\roaming\python\python37\site-packages (from requests<3.0.0,>=2.20.0->azure-iot-device) (3.0.4)

PS C:\data\code\youtube\iothub\python-send-message> python --version
Python 3.7.1
PS C:\data\code\youtube\iothub\python-send-message> pip --version
pip 20.2.1 from c:\users\heman\appdata\local\programs\python\python37-32\lib\site-packages\pip (python 3.7)
PS C:\data\code\youtube\iothub\python-send-message>

我看到几个线程讨论相同的问题,但不确定解决方案是什么。

任何指针,如何在 Windows 机器上解决这个问题?

标签: pythonpython-3.xazureazure-iot-hubazure-iot-sdk

解决方案


你可以试试pip3吗?

pip3 install azure-iot-device

推荐阅读