'module' object has no attribute when using Python SDK


#1

Hello,

I’ve just started using resin.io and it’s amazing, I have successfully deployed and updated some devices but I am having problems with the Python SDK.

I have installed the resin SDK using pip, I then load a python interpreter and run ‘import resin’

However I repeatedly get a "‘module’ object has no attribute " error when i attempt to call functions

For example:

“resin.models.api_key.create_api_key(‘myApiKey’)” returns “‘module’ object has no attribute ‘create_api_key’”

“resin.get_all()” returns “‘module’ object has no attribute ‘get_all’”

I have probably made a trivial error, does anyone know what it is? :slight_smile:

Thanks!


ImportError: cannot import name Auth
#4

Got to say the Resin SDK documentation is not the clearest and some examples of how to use it would be great but I worked it out. This is my code to authenticate and then get all of the devices that belong to the “Sensors” application, then access the API on each of them.

import resin, requests
from resin import Auth

authenticator = resin.Auth()
device = resin.models.Device()

token = "mytoken"

authenticator.login_with_token(token)
devices = device.get_all_by_application("Sensors")

uuids = []
for device in devices:
    uuids.append("https://" + device['uuid'] + ".resindevice.io")

for uuid in uuids:
    print requests.get(uuid).json()

#5

Thanks for sharing that code sample!


#8

Hi @lucasamos,

i tried your code but i couldn’t get it to work. i getting this error:

AttributeError: ‘module’ object has no attribute ‘Auth’

I was wondering if you can help me? thanks!