Python Dependencies Basics


I need to replace Packer template with boto3 code that will replicate its functionality. The reason is that Packer license is confusing.

The Hive Python project is used to create a custom AMI image from a base image. The image will be made public and copied to all AWS regions. Anyone will be able to use the custom image for their own purposes for free.

OpenTofu template will use the custom AMI and provision the infrastructure on AWS for Rails 7.1 app.


Using a requirements.txt file to install dependencies for your Python project is a best practice. This file has the project dependencies in a human readable format that can be installed using pip, Python’s package installer.

Specify Requirements

  1. Create a file named requirements.txt in your project’s root directory.

The latest version of boto3 can be found at boto3 versions.

Install Dependencies

  1. Install the dependencies using pip:
Install Dependencies
pip install -r requirements.txt

This command will install boto3 and any other dependencies listed in your requirements.txt file. This approach ensures that your project’s environment is reproducible, making it easier for others to set up the project and for you to manage dependencies.

Verify Installation

  1. To check the version installed:
Check Version
python -c "import boto3; print(boto3.__version__)"

You can also use pip to check the version:

Check Version
$ pip show boto3
Boto Version Output
Name: boto3
Version: 1.34.78
Summary: The AWS SDK for Python
Author: Amazon Web Services
License: Apache License 2.0
Location: /Users/bparanj/PycharmProjects/hive/.venv/lib/python3.12/site-packages
Requires: botocore, jmespath, s3transfer