Dear Readers,
In this article, we will see the following Install Python Boto3 On AWS EC2.
Steps to Follow :
- Logging to AWS Account
- Launch Linux Server
- Connect to Linux EC2 Instance by Using Putty
- Install Python Package
- Install Boto3 Package
- Verify boto3 Package
1. Logging to AWS Account
First, we need to AWS Console page by using below link.
https://aws.amazon.com/console/
Click on sign in to Console button.
Logging to aws account
Login using username & password and click on sign in.
Enter to AWS Management Console
We can see the AWS Management Console Dashboard.
Go to Services, under the compute module click EC2 service to open.
2. Launch Linux EC2 Instance
Go to Services, under the compute module click EC2 service to open.
We can launch Windows Server by using below link.
How to Launch Linux EC2 Instance
We can see the windows server has been launched successfully.
3. Connect to Linux EC2 Instance Using Putty
We can connect putty by using below link.
Connect to EC2 Instance Using Putty
Go inside the Linux Server Terminal.
1 2 3 4 5 6 7 8 9 10 11 |
login as: ec2-user Authenticating with public key "imported-openssh-key" __| __|_ ) _| ( / Amazon Linux 2 AMI ___|\___|___| https://aws.amazon.com/amazon-linux-2/ 2 package(s) needed for security, out of 13 available Run "sudo yum update" to apply all updates. [ec2-user@ip-172-31-6-132 ~]$ |
Install Server Updates
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
[root@ip-172-31-6-132 ~]# yum update -y Loaded plugins: extras_suggestions, langpacks, priorities, update-motd amzn2-core | 3.7 kB 00:00:00 Resolving Dependencies --> Running transaction check ---> Package awscli.noarch 0:1.18.107-1.amzn2.0.1 will be updated ---> Package awscli.noarch 0:1.18.147-1.amzn2.0.1 will be an update ---> Package ec2-net-utils.noarch 0:1.4-2.amzn2 will be updated ---> Package ec2-net-utils.noarch 0:1.4-3.amzn2 will be an update ---> Package kernel.x86_64 0:4.14.198-152.320.amzn2 will be installed ---> Package kernel-tools.x86_64 0:4.14.193-149.317.amzn2 will be updated ---> Package kernel-tools.x86_64 0:4.14.198-152.320.amzn2 will be an update ---> Package p11-kit.x86_64 0:0.23.19-1.amzn2 will be updated ---> Package p11-kit.x86_64 0:0.23.21-2.amzn2.0.1 will be an update ---> Package p11-kit-trust.x86_64 0:0.23.19-1.amzn2 will be updated ---> Package p11-kit-trust.x86_64 0:0.23.21-2.amzn2.0.1 will be an update ---> Package pam.x86_64 0:1.1.8-22.amzn2 will be updated ---> Package pam.x86_64 0:1.1.8-23.amzn2.0.1 will be an update ---> Package python2-botocore.noarch 0:1.17.31-1.amzn2.0.1 will be updated ---> Package python2-botocore.noarch 0:1.18.6-1.amzn2.0.1 will be an update ---> Package python2-rpm.x86_64 0:4.11.3-40.amzn2.0.4 will be updated ---> Package python2-rpm.x86_64 0:4.11.3-40.amzn2.0.5 will be an update ---> Package rpm.x86_64 0:4.11.3-40.amzn2.0.4 will be updated ---> Package rpm.x86_64 0:4.11.3-40.amzn2.0.5 will be an update ---> Package rpm-build-libs.x86_64 0:4.11.3-40.amzn2.0.4 will be updated ---> Package rpm-build-libs.x86_64 0:4.11.3-40.amzn2.0.5 will be an update ---> Package rpm-libs.x86_64 0:4.11.3-40.amzn2.0.4 will be updated ---> Package rpm-libs.x86_64 0:4.11.3-40.amzn2.0.5 will be an update ---> Package rpm-plugin-systemd-inhibit.x86_64 0:4.11.3-40.amzn2.0.4 will be updated ---> Package rpm-plugin-systemd-inhibit.x86_64 0:4.11.3-40.amzn2.0.5 will be an update --> Finished Dependency Resolution Verifying : awscli-1.18.107-1.amzn2.0.1.noarch 16/25 Verifying : p11-kit-trust-0.23.19-1.amzn2.x86_64 17/25 Verifying : rpm-build-libs-4.11.3-40.amzn2.0.4.x86_64 18/25 Verifying : p11-kit-0.23.19-1.amzn2.x86_64 19/25 Verifying : pam-1.1.8-22.amzn2.x86_64 20/25 Verifying : kernel-tools-4.14.193-149.317.amzn2.x86_64 21/25 Verifying : rpm-libs-4.11.3-40.amzn2.0.4.x86_64 22/25 Verifying : rpm-plugin-systemd-inhibit-4.11.3-40.amzn2.0.4.x86_64 23/25 Verifying : python2-botocore-1.17.31-1.amzn2.0.1.noarch 24/25 Verifying : python2-rpm-4.11.3-40.amzn2.0.4.x86_64 25/25 Installed: kernel.x86_64 0:4.14.198-152.320.amzn2 Updated: awscli.noarch 0:1.18.147-1.amzn2.0.1 ec2-net-utils.noarch 0:1.4-3.amzn2 kernel-tools.x86_64 0:4.14.198-152.320.amzn2 p11-kit.x86_64 0:0.23.21-2.amzn2.0.1 p11-kit-trust.x86_64 0:0.23.21-2.amzn2.0.1 pam.x86_64 0:1.1.8-23.amzn2.0.1 python2-botocore.noarch 0:1.18.6-1.amzn2.0.1 python2-rpm.x86_64 0:4.11.3-40.amzn2.0.5 rpm.x86_64 0:4.11.3-40.amzn2.0.5 rpm-build-libs.x86_64 0:4.11.3-40.amzn2.0.5 rpm-libs.x86_64 0:4.11.3-40.amzn2.0.5 rpm-plugin-systemd-inhibit.x86_64 0:4.11.3-40.amzn2.0.5 Complete! |
4. Install Python Package
Python package will get by default in Amazon EC2 Instance, if not we can use this command to install the python
1 |
yum install python -y |
Verify python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
[root@ip-172-31-6-132 ~]# yum info python Loaded plugins: extras_suggestions, langpacks, priorities, update-motd Installed Packages Name : python Arch : x86_64 Version : 2.7.18 Release : 1.amzn2.0.2 Size : 79 k Repo : installed Summary : An interpreted, interactive, object-oriented programming language URL : http://www.python.org/ License : Python Description : Python is an interpreted, interactive, object-oriented programming : language often compared to Tcl, Perl, Scheme or Java. Python includes : modules, classes, exceptions, very high level dynamic data types and : dynamic typing. Python supports interfaces to many system calls and : libraries, as well as to various windowing systems (X11, Motif, Tk, : Mac and MFC). : : Programmers can write new built-in modules for Python in C or C++. : Python can be used as an extension language for applications that need : a programmable interface. : : Note that documentation for Python is provided in the python-docs : package. : : This package provides the "python" executable; most of the actual : implementation is within the "python-libs" package. |
5. Install Boto3 Package
If we install Boto3 we required pip
Download and Install pip
Download pip
1 2 3 4 5 6 7 8 9 10 11 |
[root@ip-172-31-6-132 ~]# wget https://bootstrap.pypa.io/get-pip.py --2020-10-12 05:31:34-- https://bootstrap.pypa.io/get-pip.py Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.152.175, 2a04:4e42:24::175 Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.152.175|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 1885433 (1.8M) [text/x-python] Saving to: ‘get-pip.py’ 100%[=============================================================================================>] 1,885,433 --.-K/s in 0.03s 2020-10-12 05:31:34 (68.3 MB/s) - ‘get-pip.py’ saved [1885433/1885433] |
Verify pip file
1 2 3 |
[root@ip-172-31-6-132 ~]# ll total 1844 -rw-r--r-- 1 root root 1885433 Sep 8 12:45 get-pip.py |
Install pip
1 2 3 4 5 6 7 8 9 |
[root@ip-172-31-6-132 ~]# python get-pip.py DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. Collecting pip Downloading pip-20.2.3-py2.py3-none-any.whl (1.5 MB) |████████████████████████████████| 1.5 MB 14.7 MB/s Collecting wheel Downloading wheel-0.35.1-py2.py3-none-any.whl (33 kB) Installing collected packages: pip, wheel Successfully installed pip-20.2.3 wheel-0.35.1 |
Verify pip
1 2 3 |
[root@ip-172-31-6-132 ~]# pip show DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. WARNING: ERROR: Please provide a package name or names. |
Install Boto3 Package
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
[root@ip-172-31-6-132 ~]# pip install boto3 DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. Collecting boto3 Downloading boto3-1.15.16-py2.py3-none-any.whl (129 kB) |████████████████████████████████| 129 kB 18.3 MB/s Requirement already satisfied: jmespath<1.0.0,>=0.7.1 in /usr/lib/python2.7/site-packages (from boto3) (0.9.3) Collecting botocore<1.19.0,>=1.18.16 Downloading botocore-1.18.16-py2.py3-none-any.whl (6.7 MB) |████████████████████████████████| 6.7 MB 30.3 MB/s Collecting s3transfer<0.4.0,>=0.3.0 Downloading s3transfer-0.3.3-py2.py3-none-any.whl (69 kB) |████████████████████████████████| 69 kB 13.1 MB/s Requirement already satisfied: urllib3<1.26,>=1.20; python_version != "3.4" in /usr/lib/python2.7/site-packages (from botocore<1.19.0,>=1.18.16->boto3) (1.25.7) Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /usr/lib/python2.7/site-packages (from botocore<1.19.0,>=1.18.16->boto3) (2.6.0) Requirement already satisfied: futures<4.0.0,>=2.2.0; python_version == "2.7" in /usr/lib/python2.7/site-packages (from s3transfer<0.4.0,>=0.3.0->boto3) (3.0.5) Requirement already satisfied: six>=1.5 in /usr/lib/python2.7/site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.19.0,>=1.18.16->boto3) (1.9.0) Installing collected packages: botocore, s3transfer, boto3 Attempting uninstall: botocore Found existing installation: botocore 1.18.6 Uninstalling botocore-1.18.6: Successfully uninstalled botocore-1.18.6 Attempting uninstall: s3transfer Found existing installation: s3transfer 0.1.12 Uninstalling s3transfer-0.1.12: Successfully uninstalled s3transfer-0.1.12 ERROR: After October 2020 you may experience errors when installing or updating packages. This is because pip will change the way that it resolves dependency conflicts. We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default. awscli 1.18.147 requires botocore==1.18.6, but you'll have botocore 1.18.16 which is incompatible. Successfully installed boto3-1.15.16 botocore-1.18.16 s3transfer-0.3.3 |
6. Verify boto3
1 2 3 4 5 6 7 8 9 10 11 12 |
[root@ip-172-31-6-132 ~]# pip show boto3 DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality. Name: boto3 Version: 1.15.16 Summary: The AWS SDK for Python Home-page: https://github.com/boto/boto3 Author: Amazon Web Services Author-email: UNKNOWN License: Apache License 2.0 Location: /usr/lib/python2.7/site-packages Requires: jmespath, botocore, s3transfer Required-by: |
Thank you for giving your valuable time to read the above information. Please click here to subscribe for further updates
KTEXPERTS is always active on below social media platforms.
Facebook : https://www.facebook.com/ktexperts/
LinkedIn : https://www.linkedin.com/company/ktexperts/
Twitter : https://twitter.com/ktexpertsadmin
YouTube : https://www.youtube.com/c/ktexperts
Instagram : https://www.instagram.com/knowledgesharingplatform