2

I understand Scientific Linux 6 uses Python 2.6.6 for several critical utils, including yum, according to this article How to install Python 27 on Centos 6

The simplest and hopefully cleanest install I found is based on Red Hat Software Collection and the devtoolset-3 package which I already installed according to Compiling in Scientific Linux

I stopped at the next step:

yum install python27
scl enable python27 bash

Could you advise whether it will be 'safe' to proceed further as instructed without an alt-install. Thanks.

Stephen Harris
  • 42,369
  • 5
  • 94
  • 123
slkuser
  • 23
  • 1
  • 4

1 Answers1

2

You should verify that python27 is coming from SCL and not elsewhere.

In my case I am using CentOS 6, but the process is the same.

So:

$ yum info python27  
Loaded plugins: fastestmirror, priorities
Loading mirror speeds from cached hostfile
6 packages excluded due to repository priority protections
Available Packages
Name        : python27
Arch        : x86_64
Version     : 1.1
Release     : 25.el6
Size        : 5.2 k
Repo        : centos-sclo-rh
Summary     : Package that installs python27
License     : GPLv2+
Description : This is the main package for python27 Software Collection.

We can see it comes from centos-sclo-rh and so is the right version.

We can install this. Because it's from SCL it will install into /opt/rh and this will not impact any other aspect of the OS:

$ sudo yum install python27
...
$ ls /opt/rh
python27

We can see the default python is still unchanged:

$ /usr/bin/python --version
Python 2.6.6

Now we need the scl command. This is from the scl-utils package, which you may need to install (yum install scl-utils).

$ scl enable python27 bash

This runs a new shell with the path changed:

$ scl enable python27 bash
bash-4.1$ echo $PATH
/opt/rh/python27/root/usr/bin:/usr/local/bin:/usr/bin/X11:/etc:/usr/local/sbin:/sbin:/usr/sbin
bash-4.1$ command -v python
/opt/rh/python27/root/usr/bin/python
bash-4.1$ python --version
Python 2.7.8

So enabling and running SCL does not impact the core OS; it won't break anything you normally run but allows for a newer version of python to be installed in parallel (in /opt/rh).

Stephen Harris
  • 42,369
  • 5
  • 94
  • 123
  • 1
    `/opt/rh/python27/root/usr/bin/python` is a soft link, which ends at `/opt/rh/python27/root/usr/bin/python2.7`. An alternative too using `scl` to call a new shell is to add a soft link (e.g. `/usr/local/bin/python2.7`) and explicitly state the use of `python2.7` in the scripts that need it. Hacky, yes, but still explicit enough to not confuse people that will do `which python2.7`. Good answer btw (+1) – grochmal Jul 29 '16 at 21:55
  • @Stephen: thanks so much for posting such a detailed answer. I have `slc6-scl` for repo as expected since I fetched SCL/devtoolset-3 from [SL] (https://root.cern.ch/phpBB3/viewtopic.php?t=18262). Any idea where it will install to in `/opt`? – slkuser Jul 29 '16 at 22:13
  • If the SCL stuff is built to be compatible with RH, it _should_ be in `/opt/rh` the same as the CentOS version. – Stephen Harris Jul 29 '16 at 22:16
  • 1
    Reporting back: successful install of python 2.7 in `/opt/rh` where `devtoolset-3` took residence. In short, it works for Scientific Linux 6 too. Thanks so much again. – slkuser Jul 30 '16 at 10:35