Python3 isn’t installed by default – Python 2.7 is by default.

Use 'yum'.   apt-get was in the older version of Amazon Linux.
[root@ip-x.y.z.12 ec2-user]# sudo yum install python3
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core | 3.7 kB 00:00
Resolving Dependencies
--> Running transaction check
---> Package python3.x86_64 0:3.7.9-1.amzn2.0.1 will be installed
--> Processing Dependency: python3-libs(x86-64) = 3.7.9-1.amzn2.0.1 for package: python3-3.7.9-1.amzn2.0.1.x86_64
--> Processing Dependency: python3-setuptools for package: python3-3.7.9-1.amzn2.0.1.x86_64
--> Processing Dependency: python3-pip for package: python3-3.7.9-1.amzn2.0.1.x86_64
--> Processing Dependency: libpython3.7m.so.1.0()(64bit) for package: python3-3.7.9-1.amzn2.0.1.x86_64
--> Running transaction check
---> Package python3-libs.x86_64 0:3.7.9-1.amzn2.0.1 will be installed
---> Package python3-pip.noarch 0:9.0.3-1.amzn2.0.2 will be installed
---> Package python3-setuptools.noarch 0:38.4.0-3.amzn2.0.6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
python3 x86_64 3.7.9-1.amzn2.0.1 amzn2-core 71 k
Installing for dependencies:
python3-libs x86_64 3.7.9-1.amzn2.0.1 amzn2-core 9.2 M
python3-pip noarch 9.0.3-1.amzn2.0.2 amzn2-core 1.9 M
python3-setuptools noarch 38.4.0-3.amzn2.0.6 amzn2-core 617 k

Transaction Summary
================================================================================
Install 1 Package (+3 Dependent packages)

Total download size: 12 M
Installed size: 50 M
Is this ok [y/d/N]: y
Downloading packages:
(1/4): python3-3.7.9-1.amzn2.0.1.x86_64.rpm | 71 kB 00:00
(2/4): python3-pip-9.0.3-1.amzn2.0.2.noarch.rpm | 1.9 MB 00:00
(3/4): python3-setuptools-38.4.0-3.amzn2.0.6.noarch.rpm | 617 kB 00:00
(4/4): python3-libs-3.7.9-1.amzn2.0.1.x86_64.rpm | 9.2 MB 00:00
--------------------------------------------------------------------------------
Total 22 MB/s | 12 MB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python3-pip-9.0.3-1.amzn2.0.2.noarch 1/4
Installing : python3-libs-3.7.9-1.amzn2.0.1.x86_64 2/4
Installing : python3-3.7.9-1.amzn2.0.1.x86_64 3/4
Installing : python3-setuptools-38.4.0-3.amzn2.0.6.noarch 4/4
Verifying : python3-setuptools-38.4.0-3.amzn2.0.6.noarch 1/4
Verifying : python3-pip-9.0.3-1.amzn2.0.2.noarch 2/4
Verifying : python3-libs-3.7.9-1.amzn2.0.1.x86_64 3/4
Verifying : python3-3.7.9-1.amzn2.0.1.x86_64 4/4

Installed:
python3.x86_64 0:3.7.9-1.amzn2.0.1

Dependency Installed:
python3-libs.x86_64 0:3.7.9-1.amzn2.0.1
python3-pip.noarch 0:9.0.3-1.amzn2.0.2
python3-setuptools.noarch 0:38.4.0-3.amzn2.0.6

Complete!
[root@ip-x.y.z-123 ec2-user]# python3
Python 3.7.9 (default, Aug 27 2020, 21:59:41)
[GCC 7.3.1 20180712 (Red Hat 7.3.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
[root@ip-x.y.z.123 ec2-user]# python
Python 2.7.18 (default, Aug 27 2020, 21:22:52)
[GCC 7.3.1 20180712 (Red Hat 7.3.1-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
[root@ip-x.y.z-123 ec2-user]# pip3

Usage:
pip <command> [options]

 

Leave a Reply