0

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.

1 Answers1

1

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.

jp-jee
  • 1,502
  • 3
  • 16
  • 21
  • New error on line 13 > AttributeError: 'Client' object has no attribute 'send_message' (Also, please note that the code works perfectly fine on my old machine) – James James Jul 13 '19 at 18:43
  • There's a function `send_request`. When you migrate software from an older to a more up-to-date system (newer version of a library in your case), it is pretty likely that you'll have to make some adaptions to your code. You should have a look at the (current version of) source code and documenation of the libraries you've used. I suspect that your old machine had an older version of that library installed. – jp-jee Jul 13 '19 at 18:48
  • Not sure what to do with your comment :/ – James James Jul 13 '19 at 18:50
  • After a little time. I read the doc you read from (plivo-python) and decided to edit the script creator I had made to properly syntax everything. I used client = plivo.RestClient && message_created = client.messages.create... the old script was very badly coded (but does the job still) – James James Jul 13 '19 at 20:13