Installing from RPM is generally better, because:
- you can install and uninstall (properly) python3.
- the installation time is way faster. If you work in a cloud environment with multiple VMs, compiling python3 on each VMs is not acceptable.
Solution 1: Red Hat & EPEL repositories
Red Hat has added through the EPEL repository:
- Python 3.4 for CentOS 6
- Python 3.6 for CentOS 7
[EPEL] How to install Python 3.4 on CentOS 6
sudo yum install -y epel-release
sudo yum install -y python34
# Install pip3
sudo yum install -y python34-setuptools # install easy_install-3.4
sudo easy_install-3.4 pip
You can create your virtualenv using pyvenv:
pyvenv /tmp/foo
[EPEL] How to install Python 3.6 on CentOS 7
With CentOS7, pip3.6 is provided as a package :)
sudo yum install -y epel-release
sudo yum install -y python36 python36-pip
You can create your virtualenv using pyvenv:
python3.6 -m venv /tmp/foo
If you use the pyvenv script, you'll get a WARNING:
$ pyvenv-3.6 /tmp/foo
WARNING: the pyenv script is deprecated in favour of `python3.6 -m venv`
Solution 2: IUS Community repositories
The IUS Community provides some up-to-date packages for RHEL & CentOS. The guys behind are from Rackspace, so I think that they are quite trustworthy...
https://ius.io/
Check the right repo for you here:
https://ius.io/setup
[IUS] How to install Python 3.6 on CentOS 6
sudo yum install -y https://repo.ius.io/ius-release-el6.rpm
sudo yum install -y python36u python36u-pip
You can create your virtualenv using pyvenv:
python3.6 -m venv /tmp/foo
[IUS] How to install Python 3.6 on CentOS 7
sudo yum install -y https://repo.ius.io/ius-release-el7.rpm
sudo yum install -y python36u python36u-pip
You can create your virtualenv using pyvenv:
python3.6 -m venv /tmp/foo
Answer from Samuel Phan on Stack OverflowInstalling from RPM is generally better, because:
- you can install and uninstall (properly) python3.
- the installation time is way faster. If you work in a cloud environment with multiple VMs, compiling python3 on each VMs is not acceptable.
Solution 1: Red Hat & EPEL repositories
Red Hat has added through the EPEL repository:
- Python 3.4 for CentOS 6
- Python 3.6 for CentOS 7
[EPEL] How to install Python 3.4 on CentOS 6
sudo yum install -y epel-release
sudo yum install -y python34
# Install pip3
sudo yum install -y python34-setuptools # install easy_install-3.4
sudo easy_install-3.4 pip
You can create your virtualenv using pyvenv:
pyvenv /tmp/foo
[EPEL] How to install Python 3.6 on CentOS 7
With CentOS7, pip3.6 is provided as a package :)
sudo yum install -y epel-release
sudo yum install -y python36 python36-pip
You can create your virtualenv using pyvenv:
python3.6 -m venv /tmp/foo
If you use the pyvenv script, you'll get a WARNING:
$ pyvenv-3.6 /tmp/foo
WARNING: the pyenv script is deprecated in favour of `python3.6 -m venv`
Solution 2: IUS Community repositories
The IUS Community provides some up-to-date packages for RHEL & CentOS. The guys behind are from Rackspace, so I think that they are quite trustworthy...
https://ius.io/
Check the right repo for you here:
https://ius.io/setup
[IUS] How to install Python 3.6 on CentOS 6
sudo yum install -y https://repo.ius.io/ius-release-el6.rpm
sudo yum install -y python36u python36u-pip
You can create your virtualenv using pyvenv:
python3.6 -m venv /tmp/foo
[IUS] How to install Python 3.6 on CentOS 7
sudo yum install -y https://repo.ius.io/ius-release-el7.rpm
sudo yum install -y python36u python36u-pip
You can create your virtualenv using pyvenv:
python3.6 -m venv /tmp/foo
It is easy to install python manually (i.e. build from source):
Download (there may be newer releases on Python.org):
$ wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xzUnzip
$ tar xf Python-3.* $ cd Python-3.*Prepare compilation
$ ./configureBuild
$ makeInstall
$ make installOR if you don't want to overwrite the
pythonexecutable (safer, at least on some distrosyumneedspythonto be 2.x, such as for RHEL6) - you can installpython3.*as a concurrent instance to the system default with analtinstall:$ make altinstall
Now if you want an alternative installation directory, you can pass --prefix to the configurecommand.
Example: for 'installing' Python in /opt/local, just add --prefix=/opt/local.
After the make install step: In order to use your new Python installation, it could be, that you still have to add the [prefix]/bin to the $PATH and [prefix]/lib to the $LD_LIBRARY_PATH (depending of the --prefix you passed)
Installing python on CentOS - Unix & Linux Stack Exchange
Trying to install python3.9 on CentOS 7
Problem installing Python 3.9 RPM with yum on Centos 7
Python 3.8 not possible to install on Linux? Why?
Videos
All versions of CentOS come with python pre-installed. Version 5 has python 2.4, 6 has 2.6, and 7 has 2.7. If you need python 2.7 on an old version of CentOS, you can use the IUS repos.
To use the repo, you need to install the release RPM for your version of CentOS. For CentOS 6:
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-14.ius.centos6.noarch.rpm
Once the repo is setup, you can use yum to install the alternate versions of python:
yum install python27 python34
Note that this does not change the default version of python. It is an alternate installation, so you need to specify python27 or python34 to use them.
Any luck through YUM command?
Below command can give you more information about python packages along with versions that are installed & available as updates.
yum list python --showduplicates
If you find any package with version that meets your need, then install it by:
yum install python-<version>