How do I create a Python 3 virtual environment with the Boto 3 library on Amazon Linux 2?

To Nha Notes | Aug. 1, 2022, 12:16 p.m.

Short description

To create an isolated Python environment for Amazon Linux 2, you must:

1.    Install Python 3 for Amazon Linux 2.

2.    Install a virtual environment under the ec2-user home directory.

3.    Activate the environment, and then install Boto 3.

 

Resolution

yum install python3 -y

python3 -m venv my_app/env

source ~/my_app/env/bin/activate

pip install pip --upgrade

pip install boto3

(env) [ec2-user ~]$ python

 

References

https://aws.amazon.com/premiumsupport/knowledge-center/ec2-linux-python3-boto3/

https://tecadmin.net/install-python-3-9-on-amazon-linux/