How to install Boto, Boto3 and set Amazon EC2 Keys? Boto: A Python interface SDK for Amazon Web Services

Last updated
App Shah

Crunchify » macOS Tutorials » How to install Boto, Boto3 and set Amazon EC2 Keys? Boto: A Python interface SDK for Amazon Web Services

How to install Boto3 on Mac - Amazon AWS SDK

What is Boto?

Boto is an Amazon AWS SDK for python. Ansible internally uses Boto to connect to Amazon EC2 instances and hence you need Boto library in order to run Ansible on your laptop/desktop.

Recently I started playing with Amazon EC2 and wanted to start, stop Amazon EC2 instances using command line.

One of the requirement for you to install Amazon CLI (Command Line Interface) is to install Boto on your system. I’m using Macbook Pro 13″ for all of my development.

In this tutorial we will go over steps on how to install Boto and Boto3 on MacOS.

Here are commands:


Install BOTO3.

Command: pip install boto3 --user

bash1.2 $ pip install boto3 --user

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting boto3
  Downloading (128kB)
    100% || 133kB 808kB/s 
Collecting s3transfer<0.3.0,>=0.2.0 (from boto3)
  Using cached
Collecting jmespath<1.0.0,>=0.7.1 (from boto3)
  Using cached
Collecting botocore<1.13.0,>=1.12.143 (from boto3)
  Downloading (5.4MB)
    100% || 5.4MB 3.4MB/s 
Collecting futures<4.0.0,>=2.2.0; python_version == "2.6" or python_version == "2.7" (from s3transfer<0.3.0,>=0.2.0->boto3)
Collecting urllib3<1.25,>=1.20; python_version == "2.7" (from botocore<1.13.0,>=1.12.143->boto3)
  Using cached
Collecting python-dateutil<3.0.0,>=2.1; python_version >= "2.7" (from botocore<1.13.0,>=1.12.143->boto3)
  Using cached
Collecting docutils>=0.10 (from botocore<1.13.0,>=1.12.143->boto3)
  Downloading (543kB)
    100% || 552kB 1.1MB/s 
Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1; python_version >= "2.7"->botocore<1.13.0,>=1.12.143->boto3)
  Using cached
matplotlib 1.3.1 requires nose, which is not installed.
matplotlib 1.3.1 requires tornado, which is not installed.
Installing collected packages: futures, urllib3, jmespath, six, python-dateutil, docutils, botocore, s3transfer, boto3

Successfully installed boto3-1.9.143 botocore-1.12.143 docutils-0.14 futures-3.2.0 jmespath-0.9.4 python-dateutil-2.8.0 s3transfer-0.2.0 six-1.12.0 urllib3-1.24.3

As you see in above log it’s complaining about missing nose and tornado dependencies.

Just execute below command to install both dependencies.

bash1.2 $ pip install nose --user
bash1.2 $ pip install tornado --user


Install BOTO too:

pip install boto --user

That’s it.

Step-3: Setup Amazon AWS Credentials (2 approaches)

1. Setup Boto config file:

  1. Open boto config file
    • $ vi /etc/boto.cfg
  2. Add below line to the file.
aws_access_key_id = QAYXNIWNWKSWIY27AIF
aws_secret_access_key = W8S8RyJwSCRKOAKIAYXNIWNWKSWIY27AIFokKTqcaNV


2. Setup aws credentials file:

  1. Open credentials file using command
    • vi ~/.aws/credentials
  2. Add below line to the file.
bash-3.2$ cat ~/.aws/credentials

How to set default Amazon EC2 region?

  1. Open config file using command
    • vi ~/.aws/config
  2. Add below lines to the file.

That’s it. Now you have successfully setup Boto3 and you are now good to run Ansible command and Amazon CLI.

Leave a Comment