Installing Python 3 on RHEL - Stack Overflow
Yum but written with Python 3?
Messed up my Python installation, now Yum won't work, how to reinstall yum and it's dependencies
These should more or less be all the dependencies you need for yum to work:
cpio-0:2.11-27.el7.x86_64 yum-metadata-parser-0:1.1.4-10.el7.x86_64 diffutils-0:3.3-5.el7.x86_64 diffutils-0:3.3-5.el7.i686 python-0:2.7.5-88.el7.x86_64 python-iniparse-0:0.4-9.el7.noarch pygpgme-0:0.3-9.el7.x86_64 rpm-python-0:4.11.3-43.el7.x86_64 pyliblzma-0:0.5.3-11.el7.x86_64 rpm-0:4.11.3-43.el7.x86_64 pyxattr-0:0.5.1-5.el7.x86_64 python-urlgrabber-0:3.10-10.el7.noarch yum-plugin-fastestmirror-0:1.1.31-54.el7_8.noarch
I am on 7.8.2003, but it should still use the same repository as you. You can find the packages here, under os and updates http://mirror.centos.org/centos/7/
As an example for the python package:
rpm --reinstall -v http://mirror.centos.org/centos/7/os/x86_64/Packages/python-2.7.5-88.el7.x86_64.rpm
I don't know what all you will need to get things working again, but this should help you get started
More on reddit.comTrying to install python3.9 on CentOS 7
Videos
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
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)