-1

I am getting this error when running python script for Azure ServiceBus.

Is the file in the wrong location, or am I importing it incorrectly?

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 path: pi@raspberrypi:~/azure-sdk-for-python $

Python script path:

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
SiHa
  • 7,830
  • 13
  • 34
  • 43
Sachin Prasad
  • 5,365
  • 12
  • 54
  • 101

1 Answers1

1

Your Python interpreter does not found the packages. It can be for several reasons:

  • You didn't install correctly the SDK (files are missing). You can use pip, "git clone" from the repo directly, or copy/pasting the "azure-servicebus" zip from PyPI and unzip it. Since you didn't share the content of your pi@raspberrypi:~/azure-sdk-for-python folder, I can't tell. Don't forget the dependencies if you manually install the code.
  • Your path to packages is not well defined. Again, can be fixed several ways, by defining a PYTHONPATH or changing your sys.path
Community
  • 1
  • 1
Laurent Mazuel
  • 3,422
  • 13
  • 27