Python with Edison Board - ERROR from ubidots import ApiClient


#1

Hello guys,
Im trying to connect my edison board to the ubidots cloud with python. However when I try to import the ApiClient

from ubidots import ApiClient
Traceback (most recent call last):
File “”, line 1, in
File “/home/root/ubidots.py”, line 10, in
ImportError: cannot import name ApiClient

Can someone help me ?

Thanks in advance,


#2

Hi @andrelmbraga,

Could you show me your code please ?

All the best,
Catalina M.


#3

I followed the tutorial in ubidots website

https://ubidots.com/docs/devices/intelEdison.html#setup

import time, mraa
from ubidots import ApiClient

#Connect to Ubidots

for i in range(0,5):
try:
print “Connecting to Ubidots”
api = ApiClient(token=‘d195c0044fcasdfdf9dsfab9d653af3’) # Replace with your Ubidots Token here
break

except:
    print "No internet connection, retrying..."
    time.sleep(5)

Assign analog pins

a0 = mraa.Aio(0)
a1 = mraa.Aio(1)

Read analog pins and send values to Ubidots

while(1):
try:
api.save_collection([{‘variable’: ‘Put_Here_Your_Variable_ID_1’,‘value’:a0.read()}, {‘variable’: ‘Put_Here_Your_Variable_ID_2’,‘value’:a1.read()}])
except:
print(“Couldn’t send data.”)
continue


#4

Looks like the Ubidots library isn’t installed in your system. Could you try installing it again and posting the output of the action?

pip install ubidots

If you don’t see any error message in the output, try executing your program again, please.

Have a great day :grinning: