Search code examples
pythonrestdebianplivo

Unexpected python error - module has no attributes (but it should)


AttributeError - Module object has no attribute

This script is generated by another python script which works fine.

I recently ported all to a new server (from wheezy to stretch)

I'm using plivo python SDK (installed with python -m pip install plivo)

The scripts are working fine, say I upload one generated on my new machine to the old machine, the script works fine, so that's not the issue.

File "test.py", line 6, in <module>
p = plivo.RestAPI(auth_id, auth_token)
AttributeError: 'module' object has no attribute 'RestAPI'

but the script goes as follow:

import plivo
auth_id = 'myapiauthcode'
auth_token = 'myauthtoken'
p = plivo.RestAPI(auth_id, auth_token)

For some reason, I get the above mentionned error on my new system.

Basically it says RestAPI has no attributes, but they are clearly declared... Not sure I understand what to do with this error.


Solution

  • From the plivo GitHub page:

    client = plivo.RestClient(auth_id='your_auth_id', auth_token='your_auth_token')
    

    Thus, the library might have been updated over time and the class name has changed from RestAPI to RestClient.