153

I'm trying to install python3 on RHEL using the following steps:

yum search python3

Which returned No matches found for: python3

Followed by:

yum search python

None of the search results contained python3. What should I try next?

alex
  • 6,818
  • 9
  • 52
  • 103
Chander Shivdasani
  • 9,878
  • 20
  • 76
  • 107
  • I suspect RHEL doesn't include Python 3 yet. You may be able to install an RPM built for Fedora: https://admin.fedoraproject.org/pkgdb/acls/name/python3 – Thomas K Nov 10 '11 at 23:42
  • You could also always install from source. – Danica Nov 11 '11 at 00:47
  • Just noting the EPEL review request for Python 3.4 here: https://bugzilla.redhat.com/show_bug.cgi?id=1219411 Once that is resolved, I (or someone else) will post a new answer with the EPEL details. – ncoghlan Jul 01 '15 at 06:16
  • 3
    Samuel Phan's answer using community yum repos is better than building from source, for exactly the reasons Samuel stated. You should change the accepted answer to his. – Edward Ned Harvey Mar 09 '18 at 13:53

19 Answers19

255

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
Samuel Phan
  • 4,218
  • 2
  • 17
  • 18
  • 1
    Fixed the IUS release package URL. they have updated the version, that's all. If they update the package again, you can check the link to their RPM from the webpage. – Samuel Phan Jul 03 '15 at 14:54
  • // , This results in the following error: `Setting up Install Process Cannot open: https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/ius-release-1.0-14.ius.centos6.noarch.rpm. Skipping. Error: Nothing to do` on CEntOS 6.3. – Nathan Basanese Sep 03 '15 at 20:39
  • Your link seems to have some weird characters in it. Please, if the URL of the RPM is wrong (because of updates from IUS side), check their website directly for the right RPM for your distro. – Samuel Phan Sep 04 '15 at 10:00
  • // , At the moment, this answer no longer works for CEntOS 6. Test the link from the answer. I think it's a dead link. Here's the nearest one from the same website: https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/python34u-3.4.3-2.ius.centos6.x86_64.rpm – Nathan Basanese Sep 04 '15 at 17:40
  • 1
    As I said, the link in your answer contains non-printable unicode characters. When I copy/paste your link, here is what I see in VIM: `https://dl.iuscommunity.org/pub/ius/stable/CentOS/6/x86_64/iu<200c><200b>s-release-1.0-14.iu‌​s.centos6.noarch.rpm` Here is the unicode character: http://www.fileformat.info/info/unicode/char/200c/index.htm The URL in my original answer works, I've just tested it. – Samuel Phan Sep 07 '15 at 09:01
  • 1
    I've been told that IUS community repository is not as reliable as Software Collections so I would go with [Mike Guerette's answer](http://stackoverflow.com/a/32250834/1189651) on CentOS 6 – bformet Sep 24 '15 at 08:18
  • Software Collections are RedHat stuff, so I believe also that they are more reliable than other community repo, but Software Collections adds more complexity to use it. You need to enable a shell (bash) that will have the new version of python in your PATH. Combined to virtualenvs, I feel like it'd turn as a pain in the neck... – Samuel Phan Sep 24 '15 at 14:22
  • 2
    Using this solution, how would you then install pip for python34 ? – Loïc Sep 30 '15 at 13:48
  • 1
    Very good question, I added a comment for that. It's the best I found. If you want to stick to RPM-based installation, you should use IUS repositories for CentOS 7. They provide a `python34u-pip`. – Samuel Phan Oct 01 '15 at 21:11
  • // , I can confirm that the CEntOS 7 instructions work on CEntOS 7.1. – Nathan Basanese Nov 05 '15 at 20:10
  • I installed python3.5 using this method. But I can't 'pyvenv'. Where is it? – Jian Chen Mar 06 '16 at 05:16
  • If you installed the package `python35u-3.5.1-2.ius.centos7.x86_64` from the IUS repo on CentOS 7.2, you should have it: `pyvenv-3.5 --help`. You can look for it using this command: `yum provides '*/pyvenv*'` – Samuel Phan Mar 07 '16 at 17:14
  • Argh the the `u` suffix is important. Was going crazy trying to install `python35`, should have been `install python35u` on CentOS 6.7 – Gerard Aug 23 '16 at 11:06
  • Yes, I don't know why the IUS repo has this `u` suffix... if you know, I would be glad to know. – Samuel Phan Aug 24 '16 at 13:15
  • For 3.5 on CentOS 6, I also needed to do `sudo yum install python35u-devel` to get `pip install mysqlclient` to work. – Adam Barnes Sep 30 '16 at 09:08
  • Yes, but it's not strictly related to Python installation. Some Python libs need to be **compiled**, and to do so, they need Python headers as well, which are in the package `python*-devel`. It's true for `psycopg2` and many other Python libs. – Samuel Phan Sep 30 '16 at 09:42
  • 1
    `easy_install pip3` should work--or a variation of it--to get pip3 installed without needing to `curl` a specific URL that may or may not be there (anymore). – ILMostro_7 May 05 '17 at 02:27
  • Very good point, @ILMostro_7 I'll edit my post! Thanks! For the `pyvenv` though, we still need to curl `pip` manually... – Samuel Phan May 05 '17 at 10:20
  • REDHAT not CENTOS – shrewmouse Nov 26 '18 at 22:05
  • I don't have RedHat subscription, but RedHat and CentOS packages are the same. Now, RedHat seems to populate EPEL with the close-to-latest versions of Python (3.6 when writing this). The `dist` tag of the packages is `el7` for RHEL 7 and all variants (like CentOS). – Samuel Phan Nov 28 '18 at 10:05
  • Python 3.6 is now available via EPEL: https://pkgs.org/download/python36 – phoenix Apr 03 '19 at 00:24
205

It is easy to install python manually (i.e. build from source):

  1. Download (there may be newer releases on Python.org):

     $ wget https://www.python.org/ftp/python/3.4.3/Python-3.4.3.tar.xz
    
  2. Unzip

     $ tar xf Python-3.* 
     $ cd Python-3.*
    
  3. Prepare compilation

     $ ./configure
    
  4. Build

     $ make
    
  5. Install

     $ make install
    

    OR if you don't want to overwrite the python executable (safer, at least on some distros yum needs python to be 2.x, such as for RHEL6) - you can install python3.* as a concurrent instance to the system default with an altinstall:

     $ 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)

Trevor Boyd Smith
  • 18,164
  • 32
  • 127
  • 177
gecco
  • 17,969
  • 11
  • 51
  • 68
  • 11
    You used: bzip2 -cd Python-3.2.2.tar.bz2 | tar xvf - This is also a simpler posiblity: tar jxvf Python-3.2.2.tar.bz2 – rajadhiraja Jul 09 '12 at 17:58
  • 1
    The bzip2 option to tar was `-y` on some early systems, before bzip2 was "officially" supported, and some systems that don't use GNU tar don't even have bzip2 support built-in (but may have bzip2 binaries). So depending on how portable things need to be, the `bunzip2 -c` command (or `bzip2 -cd`) may be more portable. RHEL6, as in teh question, supports `-j`, so this is moot for the actual question. But for posterity... – dannysauer Oct 29 '14 at 21:38
  • 1
    I got a 301 (moved) into a 404 when using the bz2 tar. I changed it to .tgz and it downloaded fine. – Caleb Jan 08 '15 at 20:39
  • 2
    And for me, the resultant binary was named python3.5 and lives here: [root@machine python3.5]# which python3.5 **/usr/local/bin/python3.5** So you might want to add a symlink to this named **python3** for convenience – Will May 27 '16 at 14:36
  • 8
    if you get `no acceptable C compiler found in $PATH when installing python` reffer to [http://stackoverflow.com/questions/19816275/no-acceptable-c-compiler-found-in-path-when-installing-python](http://stackoverflow.com/questions/19816275/no-acceptable-c-compiler-found-in-path-when-installing-python) – bnu Jun 03 '16 at 13:10
  • Looks to be a good solution, but what about setting the path?, still having some trouble finding the right solution for this, and it would save much hair-pulling if it were right here ... – Paul Nelligan Aug 17 '16 at 09:20
  • 7
    `./configure --with-ensurepip=install` to enable `pip3`, or you won't have `pip3` installed after compilation. – Searene Nov 20 '16 at 03:44
  • make install depends on zlib and If you get "zipimport.ZipImportError: can't decompress data; zlib not available", you can install it by : yum install zlib-devel – smishra Jun 06 '18 at 16:20
  • @Searene in Python 3.7.1 install if you get ``No module named '_ctypes'`` error it's because of pip. What worked for me is to configure like so: ``./configure --prefix=/home/kmiklas/python3 --without-ensurepip`` see https://bugs.python.org/issue31652 – kmiklas Nov 01 '18 at 20:36
  • with this the python path differs. The standard python is still in python 2.7 python --version Python 2.7.5 But if i put python3 python3 --version Python 3.6.3 – Barath Ravichander Feb 19 '19 at 06:43
  • 1
    The problem with installing manually is that you need to manually keep it up-to-date when security patches are released. One of the RPM-based answers is far preferable. – Paul Gear Apr 05 '19 at 04:21
  • tanks,jsud zxvf for tgz – sirmagid Jan 13 '20 at 14:52
  • 3
    This is ridiculous in this day and age where IBM/Redhat has repos and an army of engineers that we have to compile and install from source. Why does IBM & Redhat hate Python? This is BS. – user10664542 Feb 11 '20 at 05:49
  • 1
    This answer was selected as the solution but https://stackoverflow.com/a/23317640/59984 is much better for almost all users. Using a repository means that you don't need to install a huge number of dependencies and, most importantly, you are far more likely to actually install security updates — I normally see these home-grown installs in audit reports. – Chris Adams Jul 15 '20 at 15:32
  • There are few options more risky and support-endangering than building from source. sketchy environment, irreproducable build, zero validation or pedigree ... almost every idea here - even the dependendency-hell ones - are better than building from source on enterprise linux. Not that it's not possible; just that it's a bad, bad idea. – user2066657 May 12 '22 at 22:29
33

In addition to gecco's answer I would change step 3 from:

./configure

to:

./configure --prefix=/opt/python3

Then after installation you could also:

# ln -s /opt/python3/bin/python3 /usr/bin/python3

It is to ensure that installation will not conflict with python installed with yum.

See explanation I have found on Internet:

http://www.hosting.com/support/linux/installing-python-3-on-centosredhat-5x-from-source

rsc
  • 4,234
  • 2
  • 30
  • 28
  • 18
    Why `/opt`? `/usr/local` specifically exists for this purpose and that's where `./configure` with no explicit `--prefix` will place it. – cababunga Feb 12 '13 at 19:45
  • @cababunga As I wrote I have been influenced by reading tutorial from specified site. Nevertheless installing python in above way may be usable - it would be a lot easier to uninstall it (it looks like uninstall target for make is not provided). Also you could easily install various versions of python3 in specified separate directories under /opt and manually set which one to use or test. – rsc Feb 13 '13 at 11:27
  • You may also want to set up your PATH to contain the binaries folder. For me it was `export PATH=$PATH:/opt/python3/bin` – Caleb Jan 08 '15 at 21:24
11

Along with Python 2.7 and 3.3, Red Hat Software Collections now includes Python 3.4 - all work on both RHEL 6 and 7.

RHSCL 2.0 docs are at https://access.redhat.com/documentation/en-US/Red_Hat_Software_Collections/

Plus lot of articles at developerblog.redhat.com.

<opinion> Using the SCL yum repos may be better than other yum repos because the RPMs are developed/tested by Redhat (i.e. first-party RPMs instead of third-party). </opinion>

edit

Follow these instructions to install Python 3.4 on RHEL 6/7 or CentOS 6/7:

# 1. Install the Software Collections tools:
yum install scl-utils

# 2. Download a package with repository for your system.
#  (See the Yum Repositories on external link. For RHEL/CentOS 6:)
wget https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-6-x86_64/download/rhscl-rh-python34-epel-6-x86_64.noarch.rpm
#  or for RHEL/CentOS 7
wget https://www.softwarecollections.org/en/scls/rhscl/rh-python34/epel-7-x86_64/download/rhscl-rh-python34-epel-7-x86_64.noarch.rpm

# 3. Install the repo package (on RHEL you will need to enable optional channel first):
yum install rhscl-rh-python34-*.noarch.rpm

# 4. Install the collection:
yum install rh-python34

# 5. Start using software collections:
scl enable rh-python34 bash

UPDATE 2021-08-16:

  • rhel and centos version 7 are now on python 3.6 by default i believe
  • the SCL yum repo has python version 3.8 as of the date of this writing 2021-08-16 (despite the question still referencing the older python 3.4 version)
Trevor Boyd Smith
  • 18,164
  • 32
  • 127
  • 177
Mike Guerette
  • 533
  • 3
  • 6
  • 1
    // , Doesn't this require us to enable a special shell? Combined with virtualenvs, I can see that becoming a pain in the ass. – Nathan Basanese Dec 10 '15 at 23:53
  • 1
    // , Why does this require `scl enable rh-python34 bash`? What are the implications for using this later on? – Nathan Basanese Dec 10 '15 at 23:55
  • Is there a way to install python3.5 on RedHat 6? I tried `wget https://www.softwarecollections.org/en/scls/rhscl/rh-python35/epel-6-x86_64/download/rhscl-rh-python35-epel-6-x86_64.noarch.rpm`, but it was not found. – Searene Nov 20 '16 at 02:53
  • You have to subscribe to get the collections? How much does that cost? – Noumenon Dec 08 '17 at 16:00
  • 1
    There is no extra cost. RH Software Collections are part of all RHEL developer subscriptions and most RHEL subscriptions. No-cost RHEL development subscriptions can be obtained from developers.redhat.com/download. These are real RHEL subscriptions - all the same bits as production entitlements - but are for development purposes. – Mike Guerette Dec 11 '17 at 13:02
9

You can download a source RPMs and binary RPMs for RHEL6 / CentOS6 from here

This is a backport from the newest Fedora development source rpm to RHEL6 / CentOS6

Abhijeet Kasurde
  • 3,937
  • 1
  • 24
  • 33
9

Use the SCL repos.

sudo sh -c 'wget -qO- http://people.redhat.com/bkabrda/scl_python33.repo >> /etc/yum.repos.d/scl.repo'
sudo yum install python33
scl enable python27

(This last command will have to be run each time you want to use python27 rather than the system default.)

Paul Draper
  • 78,542
  • 46
  • 206
  • 285
  • 4
    After reading the redhat docs what I needed to do was either; `scl enable python33 bash` to launch a new shell which will be enabled for python 3 or `scl enable python33 'python hello.py'` which will run your python file using python 3 in the current shell – stratagem Sep 24 '14 at 13:23
  • // , What more generic instructions would also allow the installation of Python 3.4? – Nathan Basanese Aug 24 '15 at 21:46
  • If you are on RHEL, use Red Hat Software collections: `subscription-manager repos --enable rhel-7-server-optional-rpms --enable rhel-server-rhscl-7-rpms`. Then you can `yum install rh-python36`. See [How to install Python 3 on RHEL](https://developers.redhat.com/blog/2018/08/13/install-python3-rhel/) for more info. – Rob T. Aug 31 '18 at 15:40
9

Python3 was recently added to EPEL7 as Python34.

There is ongoing (currently) effort to make packaging guidelines about how to package things for Python3 in EPEL7.

See https://bugzilla.redhat.com/show_bug.cgi?id=1219411
and https://lists.fedoraproject.org/pipermail/python-devel/2015-July/000721.html

rkuska
  • 186
  • 1
  • 2
  • 4
8

If you are on RHEL and want a Red Hat supported Python, use Red Hat Software collections (RHSCL). The EPEL and IUS packages are not supported by Red Hat. Also many of the answers above point to the CentOS software collections. While you can install those, they aren't the Red Hat supported packages for RHEL.

Also, the top voted answer gives bad advice - On RHEL you do not want to change /usr/bin/python, /usr/bin/python2 because you will likely break yum and other RHEL admin tools. Take a look at /bin/yum, it is a Python script that starts with #!/usr/bin/python. If you compile Python from source, do not do a make install as root. That will overwrite /usr/bin/python. If you break yum it can be difficult to restore your system.

For more info, see How to install Python 3, pip, venv, virtualenv, and pipenv on RHEL on developers.redhat.com. It covers installing and using Python 3 from RHSCL, using Python Virtual Environments, and a number of tips for working with software collections and working with Python on RHEL.

In a nutshell, to install Python 3.6 via Red Hat Software Collections:

$ su -
# subscription-manager repos --enable rhel-7-server-optional-rpms \
   --enable rhel-server-rhscl-7-rpms
# yum -y install @development
# yum -y install rh-python36

# yum -y install rh-python36-numpy \
   rh-python36-scipy \ 
   rh-python36-python-tools \
   rh-python36-python-six

To use a software collection you have to enable it:

scl enable rh-python36 bash

However if you want Python 3 permanently enabled, you can add the following to your ~/.bashrc and then log out and back in again. Now Python 3 is permanently in your path.

# Add RHSCL Python 3 to my login environment
source scl_source enable rh-python36

Note: once you do that, typing python now gives you Python 3.6 instead of Python 2.7.

See the above article for all of this and a lot more detail.

Rob T.
  • 386
  • 3
  • 5
7

I see all the answers as either asking to compile python3 from code or installing the binary RPM package. Here is another answer to enable EPEL (Extra Packages for Enterprise Linux) and then install python using yum. Steps for RHEL 7.5 (Maipo)

yum install wget –y
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-XX.noarch.rpm # Verify actual RPM name by browsing dir over browser
rpm –ivh epel-*.rpm
yum install python36

Also see link

Jay Rajput
  • 1,813
  • 17
  • 23
  • Works well, especially if official way through SCL doesn't work. Complement pip3 install then: `sudo yum install python34-setuptools` – OSP Jan 08 '19 at 09:26
  • Link is now 404 – f01 Aug 28 '20 at 11:43
  • 1
    @f01, link works OK but you need to replace XX with the actual number. Just browse [https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/](https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/) and search for "epel-release-7-". As of today (2021-07-09) the version is 13 (epel-release-7-13.noarch.rpm) – Fer B. Jul 09 '21 at 09:23
5

I was having the same issue using the python 2.7. Follow the below steps to upgrade successfully to 3.6. You can also try this one-

  1. See before upgrading version is 2.x

    python --version
    Python 2.7.5
    
  2. Use below command to upgrade your python to 3.x version-

    yum install python3x

    replace x with the version number you want.

    i.e. for installing python 3.6 execute

    yum install python36
    
  3. After that if you want to set this python for your default version then in bashrc file add

    vi ~/.bashrc

    alias python='python3.6'
    
  4. execute bash command to apply the settings

    bash 
    
  5. Now you can see the version below

    python --version
    Python 3.6.3
    
IRSHAD
  • 2,855
  • 30
  • 39
  • This answer won't work without adding one of the 3rd party repos either EPEL or IUS. There is no python36 package in RHEL. The RHSCL package is `rh-python36`. – Rob T. Aug 31 '18 at 15:53
4

Here are the steps i followed to install Python3:

yum install wget
wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz  
sudo tar xvf Python-3.*   
cd Python-3.* 
sudo ./configure --prefix=/opt/python3    
sudo make   
sudo make install   
sudo ln -s /opt/python3/bin/python3 /usr/bin/python3

$ /usr/bin/python3    
Python 3.6.0
pevik
  • 4,523
  • 3
  • 33
  • 44
Aty
  • 269
  • 3
  • 10
  • 2
    If you build from source without installing a number of -devel dependencies (SSL, bzip, etc) you'll be missing a number of modules that depend on shared objects. Installing one of the rpm based distributions (RHSCL, EPEL, or IUS) is a better idea – Rob T. Aug 31 '18 at 15:58
4

Three steps using Python 3.5 by Software Collections:

sudo yum install centos-release-scl
sudo yum install rh-python35
scl enable rh-python35 bash

Note that sudo is not needed for the last command. Now we can see that python 3 is the default for the current shell:

python --version
Python 3.5.1

Simply skip the last command if you'd rather have Python 2 as the default for the current shell.

Now let's say that your Python 3 scripts give you an error like /usr/bin/env: python3: No such file or directory. That's because the installation is usually done to an unusual path:

/opt/rh/rh-python35/root/bin/python3

The above would normally be a symlink. If you want python3 to be automatically added to the $PATH for all users on startup, one way to do this is adding a file like:

sudo vim /etc/profile.d/rh-python35.sh

Which would have something like:

#!/bin/bash

PATH=$PATH:/opt/rh/rh-python35/root/bin/

And now after a reboot, if we do

python3 --version

It should just work. One exception would be an auto-generated user like "jenkins" in a Jenkins server which doesn't have a shell. In that case, manually adding the path to $PATH in scripts would be one way to go.

Finally, if you're using sudo pip3 to install packages, but it tells you that pip3 cannot be found, it could be that you have a secure_path in /etc/sudoers. Checking with sudo visudo should confirm that. To temporarily use the standard PATH when running commands you can do, for example:

sudo env "PATH=$PATH" pip3 --version

See this question for more details.

NOTE: There is a newer Python 3.6 by Software Collections, but I wouldn't recommend it at this time, because I had major headaches trying to install Pycurl. For Python 3.5 that isn't an issue because I just did sudo yum install sclo-python35-python-pycurl which worked out of the box.

Nagev
  • 10,835
  • 4
  • 58
  • 69
3

If you want official RHEL packages you can use RHSCL (Red Hat Software Collections)

More details:

You have to have access to Red Hat Customer Portal to read full articles.

daneel
  • 85
  • 1
  • 9
  • // , Just upvoted. Would you be willing to make a summary of what one does to use the RHSCL for this? This is a question and answer site, after all. – Nathan Basanese Aug 24 '15 at 21:55
  • 1
    The article [How to install Python 3 on RHEL](https://developers.redhat.com/blog/2018/08/13/install-python3-rhel/) has up-to-date steps for Python 3.6 via software collections and many tips for working with RHSCLs, Python, and virtual environments. – Rob T. Aug 31 '18 at 15:55
1

yum install python34.x86_64 works if you have epel-release installed, which this answer explains how to, and I confirmed it worked on RHEL 7.3

$ cat /etc/*-release
NAME="Red Hat Enterprise Linux Server"
VERSION="7.3 (Maipo)

$ type python3
python3 is hashed (/usr/bin/python3)
Community
  • 1
  • 1
amphibient
  • 29,770
  • 54
  • 146
  • 240
1

For RHEL on Amazon Linux, using python3 I had to do :

sudo yum install python34-devel

1

Full working 36 when SCL is not available (based on Joys input)

yum install wget –y
wget https://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
rpm –ivh epel-*.rpm
yum install python36

sudo yum install python34-setuptools
sudo mkdir /usr/local/lib/python3.6
sudo mkdir /usr/local/lib/python3.6/site-packages

sudo easy_install-3.6 pip

Finally activate the environment...

pyvenv-3.6 py3
source py3/bin/activate

Then python3

OSP
  • 1,458
  • 1
  • 14
  • 15
0

You can install miniconda (https://conda.io/miniconda.html). That's a bit more than just python 3.7 but the installation is very straightforward and simple.

curl https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O
sudo yum install bzip2
bash Miniconda3-latest-Linux-x86_64.sh

You'll have to accept the license agreement and choose some options in interactive mode (accept the defaults). I believe it can be also installed silently somehow.

grabantot
  • 2,111
  • 20
  • 31
0

For those working on AWS EC2 RHEL 7.5, (use sudo) enable required repos

yum-config-manager --enable rhui-REGION-rhel-server-optional
yum-config-manager --enable rhui-REGION-rhel-server-rhscl

Install Python 3.6

yum install rh-python36

Install other dependencies

yum install rh-python36-numpy  rh-python36-scipy  rh-python36-python-tools  rh-python36-python-six
Vasu
  • 25
  • 5
0

As of RHEL 8, you can install python3 directly from the official repositories:

$ podman run --rm -ti ubi8 bash
[root@453fc5c55104 /]# yum install python3                                                                                                                                                    
Updating Subscription Management repositories.                                                                                                                                                
Unable to read consumer identity                                                                                                                                                              
Subscription Manager is operating in container mode.                                                                                                                                          
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.  

...

Installed:
  platform-python-pip-9.0.3-16.el8.noarch
  python3-pip-9.0.3-16.el8.noarch
  python3-setuptools-39.2.0-5.el8.noarch
  python36-3.6.8-2.module+el8.1.0+3334+5cb623d7.x86_64      

Complete!

You can even get python 3.8:

[root@453fc5c55104 /]# yum install python38
Installed:
  python38-3.8.0-6.module+el8.2.0+5978+503155c0.x86_64
  python38-libs-3.8.0-6.module+el8.2.0+5978+503155c0.x86_64                                       
  python38-pip-19.2.3-5.module+el8.2.0+5979+f9f0b1d2.noarch                                  
  python38-pip-wheel-19.2.3-5.module+el8.2.0+5979+f9f0b1d2.noarch                                 
  python38-setuptools-41.6.0-4.module+el8.2.0+5978+503155c0.noarch                           
  python38-setuptools-wheel-41.6.0-4.module+el8.2.0+5978+503155c0.noarch                          

Complete!
Tomas Tomecek
  • 6,226
  • 3
  • 30
  • 26