How to install Python 3 on an AWS EC2 instance?

I am trying to install python 3.x on an AWS EC2 instance and:

sudo yum install python3 

does not work:

 No package python3 available. 

I googled and cannot find anyone else who has this problem, so I ask here. Do I need to manually download and install it?

+110
python amazon-web-services amazon-ec2
Dec 27 '14 at 17:54
source share
11 answers

If you do

 sudo yum list | grep python3 

you will see that although they do not have the python3 package, they have the python34 package or later, for example python36. Installing it is as simple as:

 sudo yum install python34 python34-pip 
+195
Apr 11 '15 at 16:33
source share

Note. This may be obsolete for current versions of Amazon Linux 2 from the end of 2018 (see comments), now you can install it directly through yum install python3 .

On Amazon Linux 2 , yum repositories do not have python3[4-6] by default python3[4-6] , instead there is Amazon Extras Library .

 sudo amazon-linux-extras install python3 

If you want to configure isolated virtual environments using it; using the yum install and d virtualenv tools doesn't seem to work reliably.

 virtualenv --python=python3 my_venv 

Calling the venv module / tool is less demanding and you can double check it however you want / expect with python3 --version .

 python3 -m venv my_venv 



Other things he can install (versions of January 18, 18):

 [ec2-user@x ~]$ amazon-linux-extras list 0 ansible2 disabled [ =2.4.2 ] 1 emacs disabled [ =25.3 ] 2 memcached1.5 disabled [ =1.5.1 ] 3 nginx1.12 disabled [ =1.12.2 ] 4 postgresql9.6 disabled [ =9.6.6 ] 5 python3=latest enabled [ =3.6.2 ] 6 redis4.0 disabled [ =4.0.5 ] 7 R3.4 disabled [ =3.4.3 ] 8 rust1 disabled [ =1.22.1 ] 9 vim disabled [ =8.0 ] 10 golang1.9 disabled [ =1.9.2 ] 11 ruby2.4 disabled [ =2.4.2 ] 12 nano disabled [ =2.9.1 ] 13 php7.2 disabled [ =7.2.0 ] 14 lamp-mariadb10.2-php7.2 disabled [ =10.2.10_7.2.0 ] 
+47
Jan 18 '18 at 5:12
source share

Here are the steps I used to manually install python3 for those who want to do this, since this is not super straightforward. EDIT:. It is almost easier to use yum package manager (see other answers).

Note that you probably want to do sudo yum groupinstall 'Development Tools' before you do this, otherwise the program will not be installed.

 wget https://www.python.org/ftp/python/3.4.2/Python-3.4.2.tgz tar zxvf Python-3.4.2.tgz cd Python-3.4.2 sudo yum install gcc ./configure --prefix=/opt/python3 make sudo yum install openssl-devel sudo make install sudo ln -s /opt/python3/bin/python3 /usr/bin/python3 python3 (should start the interpreter if it worked (quit() to exit) 
+35
Dec 28 '14 at 11:37
source share

EC2 (on AMI Amazon Linux) currently supports python3.4 and python3.5.

 sudo yum install python35 sudo yum install python35-pip 
+23
Apr 08 '17 at 21:05
source share

Starting with Amazon Linux 2017.09, python 3.6 is now available:

 sudo yum install python36 python36-virtualenv python36-pip 

See release notes for more information and other packages.

+19
Nov 29 '17 at 3:32 on
source share

As @NickT said, the default yum repositories on Amazon Linux 2 do not have python3 [4-6], today it uses 3.7 and, having looked at all the answers here, we can say that it will change over time.

I searched python3.6 on Amazon Linux 2, but amazon-linux-extras shows a lot of options but doesn't use python at all. in fact, you can try to find the version you know in epel :

 sudo amazon-linux-extras install epel yum search python | grep "^python3..x8" python34.x86_64 : Version 3 of the Python programming language aka Python 3000 python36.x86_64 : Interpreter of the Python programming language 
+3
Nov 28 '18 at 7:53
source share

Amazon Linux now supports python36.

python36-pip is not available. So you need to go on a different route.

 sudo yum install python36 python36-devel python36-libs python36-tools # If you like to have pip3.6: curl -O https://bootstrap.pypa.io/get-pip.py sudo python3 get-pip.py 
+2
Jul 23 '18 at 18:00
source share

In addition to all the answers already available to this question, I would like to add the steps that I took to install Python3 on an AWS EC2 instance running CentOS 7. All the details can be found here.

https://aws-labs.com/install-python-3-centos-7-2/

First, we need to enable SCL. SCL is a community project that allows you to create, install, and use multiple versions of software on the same system without affecting the default system packages.

 sudo yum install centos-release-scl 

Now that we have the SCL repository, we can install python3

 sudo yum install rh-python36 

To access Python 3.6, you need to start a new shell instance using the Software Collection scl utility:

 scl enable rh-python36 bash 

If you check the Python version now, you will notice that Python 3.6 is the default version.

 python --version 

It is important to note that Python 3.6 is the default version of Python only in this shell session. If you exit a session or open a new session from another terminal, Python 2.7 will be the default version of Python.

Now install the Python development tools by typing:

 sudo yum groupinstall 'Development Tools 

Now create a virtual environment so that Python packages are not confused by default.

 mkdir ~/my_new_project cd ~/my_new_project python -m venv my_project_venv 

To use this virtual environment,

 source my_project_venv/bin/activate 

Now you have a virtual environment configured on python3.

+1
Apr 16 '19 at 6:27
source share

https://aws.amazon.com/premiumsupport/knowledge-center/ec2-enable-epel/

please, the link is the link above, it supports and works, I do with Centos 7, and it works also

respectfully

0
May 20 '19 at 4:51
source share

Follow the instructions here: https://gist.github.com/niranjv/f80fc1f488afc49845e2ff3d5df7f83b

Make sure you change the version of Python3 as required.

0
Jun 03 '19 at 14:49
source share

In Debian derivatives such as Ubuntu, use apt. Check the apt repository for available versions of Python. Then run a command similar to the following, substituting the correct package name:

 sudo apt-get install python3 

In Red Hat and its derivatives, use yum. Check the yum repository for available versions of Python. Then run a command similar to the following, substituting the correct package name:

 sudo yum install python36 

On SUSE and derivatives, use zypper. Check the repository for available versions of Python. Then. run a command similar to the following, substituting the correct package name:

 sudo zypper install python3 
0
Sep 23 '19 at 3:10
source share



All Articles