When I call the execute the following code i get a "No module named request" fail. I have downloaded and installed the azure-sdk-for-python from here: https://github.com/Azure/azure-sdk-for-python/tree/v0.11.0

my code looks like this:

#Code for measuring pressure from an Emerson pressuretransducer. 
#The transducer outputs 4-20 mA through a resistor of 200 Ohms.
from ABE_ADCPi import ADCPi
from ABE_helpers import ABEHelpers
from azure.servicebus import ServiceBusService
import time
import os
import json

#To use shared access signature authentication, the service bus service has been created.
sbs = ServiceBusService(service_namespace=***, shared_access_key_name=***, shared_access_key_value=***)

#The setup of the ADCPi.
i2c_helper = ABEHelpers()
bus = i2c_helper.get_smbus()
adc = ADCPi(bus, 0x68, 0x69, 16)

#Declaration of variables.
offsetVoltage = 0.8
barPrmA = 0.625
mAtoVoltVoltage = 0.2

while True:
  #The convertion has been initiated from channel 1, returns voltage.
  voltage = adc.read_voltage(1)
  #print voltage

  #The measured voltage converted into Bar.
  Bar = ((voltage-offsetVoltage)/mAtoVoltVoltage)*barPrmA

  #Bar to kPa.
  kPa = Bar*100
  #The data and device number is written with json encoding.
  data = {'DeviceId':1 , 'Tryk': str(kPa)}

  #The pressure is pushed to the database.
  sbs.send_event('mrceventhub2323', json.dumps(data))


When i execute this code. It exits with this fail message:

python PressureAzure.py
Traceback (most recent call last):
  File "PressureAzure.py", line 6, in <module>
    from azure.servicebus import ServiceBusService
  File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/__init__.py", line 39, in <module>
    from .servicebusservice import ServiceBusService
  File "/usr/local/lib/python2.7/dist-packages/azure/servicebus/servicebusservice.py", line 19, in <module>
    import requests
ImportError: No module named requests

anyone around here who can help me out? I'm wondering if I need to install this module called requests ? or should it have been in installed with azure?


Okay. Nevermind this question. I fixed the problem by downloading and installing the module called requests in python. Use the command as follows (you have to have python-pip installed as well):

sudo pip install requests

This fixed my problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.