Choosing Software Collections for Alternative Python on CentOS: Decision Guide
Guide to installing a newer Python version on CentOS using Software Collections while keeping the system Python intact.
21 Dec 2025, 04:03 UTC

Decision and Constraints
State the decision: install a newer Python version (e.g., 3.8) via Software Collections (SCL) to satisfy application requirements while keeping the base system Python untouched.
Constraints: preserve yum/dnf dependency integrity, keep SELinux enforcing, receive updates through official CentOS channels, and avoid breaking system tools that rely on the default python interpreter.
Supported Options Comparison
| Option | Support Level | Ease of Upgrade | Impact on Base System |
|---|---|---|---|
| rh-python38 (SCL) | Fully supported in CentOS 7/8 repositories | yum update rh-python38* | Isolated under /opt/rh; no file conflicts |
| EPEL python38 | Community maintained; may lag | yum update python38 | Installs to /usr/bin/python38; can replace symlinks |
| Build from source | Self-maintained | Manual recompile | Files under /usr/local; risk of overwriting |
| Container image | Supported by image publisher | Pull new image | No host changes; requires runtime |
Trade-offs
- SCL provides an isolated, fully supported runtime that can be enabled/disabled with
scl enable. - EPEL packages may conflict with base python libraries and require manual alternatives management.
- Building from source gives full control but adds maintenance burden and bypasses SELinux policies.
- Containers add overhead and require a container runtime, but give the strongest isolation.
Implementation Steps
- Install the SCL repository (requires root or sudo):
Verify withsudo yum install -y centos-release-sclrpm -q centos-release-scl; it should return a version string. - Install the desired collection (example for Python 3.8):
Check installation:sudo yum install -y rh-python38rpm -q rh-python38. - Enable the collection for a shell session:
Inside this session,scl enable rh-python38 bashpython --versionshould show 3.8.x. - Run an application using the SCL without spawning a subshell:
Alternatively, adjust the shebang toscl enable rh-python38 'python my_script.py'#!/usr/bin/env scl enable rh-python38 pythonor use a wrapper script. - Confirm base system Python remains unchanged:
Should still output the default (e.g., 2.7.5 on CentOS 7 or 3.6.8 on CentOS 8)./usr/bin/python --version
Verification
- Repository presence:
rpm -q centos-release-sclreturns a version. - Package installed:
rpm -q rh-python38. - Enabled version:
scl enable rh-python38 'python --version'yields Python 3.8.x. - Base interpreter untouched:
/usr/bin/python --versionshows original.
Limitations
- SCL packages are only provided for CentOS Linux 7 and 8; CentOS Stream 9 uses modular streams, so
rh-python38may not be available. - Enabling an SCL does not change system-wide alternatives; each invocation must use
scl enableor a modified shebang. - Updates to the collection follow the SCL release schedule; major version jumps require a new package (e.g.,
rh-python39).
Rollback (if needed)
Because installing the SCL adds files under /opt/rh and modifies the package database, you can remove it:
sudo yum remove -y rh-python38Optionally remove the SCL repository package if no other collections are needed:
sudo yum remove -y centos-release-sclAfter removal, verify that
/usr/bin/pythonstill points to the system interpreter and that no application depends on the removed runtime.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.