Last modified: Mar 28, 2025 By Alexander Williams

How to Install Boto3 in Python Step by Step

Boto3 is the Amazon Web Services (AWS) SDK for Python. It allows you to interact with AWS services like S3, EC2, and more. This guide will help you install Boto3 easily.

Prerequisites

Before installing Boto3, ensure you have Python installed. Check your Python version using the command below.

 
python --version


Python 3.8.5

If you don't have Python, download it from the official website. Also, ensure pip is installed. Pip is Python's package manager.

Install Boto3 Using Pip

The easiest way to install Boto3 is using pip. Open your terminal or command prompt and run the following command.


pip install boto3

This will download and install Boto3 along with its dependencies. Wait for the installation to complete.

Verify the Installation

After installation, verify Boto3 is installed correctly. Open a Python shell and import Boto3.

 
import boto3
print(boto3.__version__)


1.20.32

If you see the version number, Boto3 is installed. If you get an error, check our guide on How To Solve ModuleNotFoundError.

Setting Up AWS Credentials

To use Boto3, you need AWS credentials. Create an IAM user in AWS and get the access key and secret key. Then, configure them using the AWS CLI.


aws configure

Follow the prompts to enter your AWS credentials. This will save them in a configuration file.

Basic Boto3 Example

Here’s a simple example to list all S3 buckets using Boto3. This ensures everything is working.

 
import boto3

# Create an S3 client
s3 = boto3.client('s3')

# List all buckets
response = s3.list_buckets()

# Print bucket names
for bucket in response['Buckets']:
    print(bucket['Name'])


my-bucket-1
my-bucket-2

If this runs without errors, your setup is complete. You can now use Boto3 to interact with AWS services.

Common Issues and Fixes

If you face issues like ModuleNotFoundError, ensure Boto3 is installed in the correct Python environment. Use pip show boto3 to check the installation path.

For credential errors, verify your AWS credentials are correct. Ensure the IAM user has the necessary permissions.

Conclusion

Installing Boto3 is simple with pip. Verify the installation and set up AWS credentials to start using it. Now you can automate AWS tasks with Python.

For more help, refer to the ModuleNotFoundError guide. Happy coding!