raspberrypi ImportError:没有名为servicebus的模块

时间:2017-01-06 15:23:44

标签: python linux azure raspberry-pi2

运行Azure ServiceBus的python脚本时出现此错误。

文件位置错误,还是导入错误?

pi@raspberrypi:~/letsroll $ python mrrobot.py

Traceback (most recent call last):
  File "mrrobot.py", line 6, in <module>
    from azure.servicebus import ServiceBusService
ImportError: No module named servicebus

Azure SDK路径: pi@raspberrypi:~/azure-sdk-for-python $

Python脚本路径:

pi@raspberrypi:~/letsroll $ ls

mrrobot.py

mrrobot.py

import RPi.GPIO as GPIO #For Controlling the Pins
import threading #To Run On Thread
import sys
import select
from azure.servicebus import ServiceBusService
import os

# Make sure you set the following:
AZURE_SERVICEBUS_NAMESPACE='mrrobot' #Your NameSpace Should Go Here
# Note: this user should have manage rights
AZURE_SERVICEBUS_SHARED_KEY_NAME='RootManageSharedAccessKey'
AZURE_SERVICEBUS_ACCESS_KEY_VALUE='MpcCdemokey'
GPIO_BCM_PIN = 17 #Pin your LED is connected to

1 个答案:

答案 0 :(得分:1)

您的Python解释器未找到包。这可能有以下几个原因:

  • 您没有正确安装SDK(文件丢失)。您可以直接从repo使用pip,“git clone”,或者从PyPI复制/粘贴“azure-servicebus”zip并解压缩。由于您没有共享lapply文件夹的内容,我无法分辨。如果手动安装代码,请不要忘记依赖项。
  • 您的包裹路径定义不明确。同样,可以通过定义PYTHONPATH或更改sys.path
  • 来修复多种方式