I am trying to attach instance profile to an EC2 instance using boto3. I am following boto3 documentation https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.associate_iam_instance_profile
But It fails with below error:
AttributeError: 'EC2' object has no attribute 'associate_iam_instance_profile'
Could you please help me with this ?
This is the code snippet
import boto3
ec2=boto3.client('ec2',region_name='ca-central-1')
response = ec2.associate_iam_instance_profile(IamInstanceProfile={'Arn': 'arn:aws:iam::1234567890:instance-profile/instanceprofilename','Name': 'instanceprofilename'},InstanceId='i-1234567890')
A help will be much appreciated.
boto3==1.4.3
Python 3.8.6
Thanks
You are referring to documentation of boto3 version 1.17.112 and you are using a bit outdated boto version. So if there is no version constraint first thing you can do is to update your boto3 version.
pip install boto3==1.17.112
Related
I'm developing an app with kivy using the boto3 library.
When I build my project on XCode, I have an error "AttributeError: module 'subprocess' has no attribute 'Popen'".
I don't understand why because I can launch my app with no problem from my computer but not with XCode...
Can someone help me ?
Thanks
I finally find a workaround thanks to this link : https://github.com/kivy/kivy-ios/issues/372
But now, I have a new issue. boto3 use this file : https://github.com/python/cpython/blob/main/Lib/multiprocessing/connection.py and Xcode gives me the following error : "ModuleNotFoundError: No module named '_multiprocessing'"
If someone has an idea...
I am trying to list executions from my Twilio flow by using this code:
https://www.twilio.com/docs/studio/rest-api/execution?code-sample=code-read-executions-filtered-by-date
I have also tried the v2 code:
https://www.twilio.com/docs/studio/rest-api/v2/execution#read-a-list-of-executions
But every time I run the Python file I get the returned statement:
AttributeError: 'Client' object has no attribute 'studio'
Unsure what I'm doing wrong...I am able to use other commands such as:
completed_calls = client.calls.list(status='completed', to=MyNumber, limit = 10)
Which works fine.
Any advice would be appreciated! Thanks! :)
Can you check to see if you have more recent version of the Twilio Python helper library?
pip show twilio
pip install --upgrade twilio
twilio-python (Changes)
https://github.com/twilio/twilio-python/blob/master/CHANGES.md
I am now using Python to download files from Dropbox, and I following this tutorial. However, it did not succeed on the first two lines of codes:
import dropbox
dbx = dropbox.Dropbox('YOUR_ACCESS_TOKEN')
My Python complains that AttributeError: 'module' object has no attribute 'Dropbox' Any ideas?
After careful examination, I found the reason is because I am using functions from dropbox-v2 while in my machine dropbox-v1 was installed.
I'm working with the google-api-python-client library with the following setup:
Python3.4.3 in a virtual environment (using pip8.1.1)
I'm getting error from the following code: AttributeError: 'module' object has no attribute 'file'
store = oauth2client.file.Storage(credential_path)
The code is from the Google Python Quickstart example and runs fine under Python 2.7.10
Thanks in advance!
I was able to get it to work by rewriting the import statement:
from oauth2client.file import Storage
Not sure why this works, but it does.
I am currently attempting to use the cex.io Python API for accessing financial data. Here is a link to github with the library: https://github.com/matveyco/cex.io-api-python
I installed it on MacOS X by using "python setup.py install" in Terminal. In the link above, it says to initialize the class we should use the following:
import cexapi
api = cexapi.api(username, api_key, api_secret)
However, when I put this code in a .py file in a directory without any other files, bash responds with:
AttributeError: 'module' object has no attribute 'api'
I am pretty sure the library is correctly installed (Python has no problem importing cexapi). It is clear to me that there is something about Python objects that I don't understand or I must have incorrectly installed the module.
Just in case it helps, I ran the following in the Python interpreter:
import cexapi
cexapi.__file__
And got the following:
'/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/cexapi-0.1-py3.4.egg/cexapi/__init__.py'
This command should show where the module is stored. Any help would be greatly appreciated, as I need to use this API. Thanks.
use upper case letters:
import cexapi
api = cexapi.API(username, api_key, api_secret)