Use the scl_source feature.

Create a new file in /etc/profile.d/ to enable your collection automatically on start up:

$ cat /etc/profile.d/enablepython35.sh
#!/bin/bash
source scl_source enable python35

See How can I make a Red Hat Software Collection persist after a reboot/logout? for background and details.

Answer from Robert Kratky on Stack Overflow
Top answer
1 of 2
9

Use the scl_source feature.

Create a new file in /etc/profile.d/ to enable your collection automatically on start up:

$ cat /etc/profile.d/enablepython35.sh
#!/bin/bash
source scl_source enable python35

See How can I make a Red Hat Software Collection persist after a reboot/logout? for background and details.

2 of 2
1

This answer would be helpful to those who have limited auth access on the server.

I had a similar problem for python3.5 in HostGator's shared hosting. Python3.5 had to be enabled every single damn time after login. Here are my 10 steps for the resolution:

  1. Enable the python through scl script python_enable_3.5 or scl enable rh-python35 bash.

  2. Verify that it's enabled by executing python3.5 --version. This should give you your python version.

  3. Execute which python3.5 to get its path. In my case, it was /opt/rh/rh-python35/root/usr/bin/python3.5. You can use this path to get the version again (just to verify that this path is working for you.)

  4. Awesome, now please exit out of the current shell of scl.

  5. Now, lets get the version again through this complete python3.5 path /opt/rh/rh-python35/root/usr/bin/python3.5 --version.

    It won't give you the version but an error. In my case, it was

/opt/rh/rh-python35/root/usr/bin/python3.5: error while loading shared libraries: libpython3.5m.so.rh-python35-1.0: cannot open shared object file: No such file or directory
  1. As mentioned in Tamas' answer, we gotta find that so file. locate doesn't work in shared hosting and you can't install that too.

    Use the following command to find where that file is located:

find /opt/rh/rh-python35 -name "libpython3.5m.so.rh-python35-1.0"
  1. Above command would print the complete path (second line) of the file once located. In my case, output was
find: `/opt/rh/rh-python35/root/root': Permission denied
/opt/rh/rh-python35/root/usr/lib64/libpython3.5m.so.rh-python35-1.0
  1. Here is the complete command for the python3.5 to work in such shared hosting which would give the version,
LD_LIBRARY_PATH=/opt/rh/rh-python35/root/usr/lib64 /opt/rh/rh-python35/root/usr/bin/python3.5 --version
  1. Finally, for shorthand, append the following alias in your ~/.bashrc
alias python351='LD_LIBRARY_PATH=/opt/rh/rh-python35/root/usr/lib64 /opt/rh/rh-python35/root/usr/bin/python3.5'
  1. For verification, reload the .bashrc by source ~/.bashrc and execute python351 --version.

Well, there you go, now whenever you login again, you have got python351 to welcome you.

This is not just limited to python3.5, but can be helpful in case of other scl installed softwares.

Discussions

How to add packages to SCL
A few things: Is this RHEL 7 or RHEL 8? Python is not provided as an SCL in RHEL 8, but rather as Modularity modules/streams. Python 3.7 doesn't exist on RHEL 8, did you mean Python 3.6/3.8? Python 3.9 doesn't exist as an SCL on RHEL 7. If you installed Python in any of the following ways (on RHEL 8): yum module install python36 python38 python39 yum install python36 python38 python39 Then you've installed the module streams, and these packages are installed at the global level, so you can use them by calling python3.6, python3.8, and python3.9 directly. You can also set which one you'd like to be python3 by modifying the /etc/alternatives through update-alternatives. The only SCLs on RHEL 8 to my knowledge are the gcc-toolsets. https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/installing_managing_and_removing_user-space_components/introduction-to-modules_using-appstream More on reddit.com
🌐 r/redhat
2
4
April 22, 2022
python - How to use scl enable to run python3 app in dockerfile - Stack Overflow
/usr/bin/scl_enable" RUN echo -e "\n\ unset BASH_ENV PROMPT_COMMAND ENV\n\ source scl_source enable rh-python38\n\ " > /usr/bin/scl_enable RUN \ python3 -m ensurepip && \ python3 -m pip install --upgrade pip && \ python3 -m pip install setuptools wheel More on stackoverflow.com
🌐 stackoverflow.com
June 4, 2019
python - How can I make Python3.6, Red Hat Software Collection, persist after a reboot/logout/login? - Stack Overflow
I am trying to enable rh-python36 software collection after reboot So I can avoid calling "scl enable" all the time. After unzipping and installing the package: yum install -y tmp/rpms/* I creat... More on stackoverflow.com
🌐 stackoverflow.com
How to use scl enable python command call with in bash shell script?
I have a bash shell script, within it i am using the below two commands . its failing right on scl enable command itself. if i run it by itself without a shell, it works fine. by default it is using pythin version 2.6 something. i want to use 3.4 version for that reason with in the shell script ... More on unix.com
🌐 unix.com
0
0
January 24, 2019
🌐
Red Hat
access.redhat.com › solutions › 527703
How can I make a Red Hat Software Collection persist after a reboot/logout? - Red Hat Customer Portal
How the software collection concept ... are set using "scl enable python33 ..." call, which basically executes a bash script located in /opt/rh/python33/enable....
🌐
Oracle Linux
yum.oracle.com › oracle-linux-python.html
Python for Oracle Linux | Oracle, Software. Hardware. Complete.
To enable and use Python 3.8 from the SCL: $ scl enable rh-python38 bash $ python
🌐
LinuxTut
linuxtut.com › en › 592483c7625e881d771f
Install Python 3.8 on CentOS 7 (SCL)
June 24, 2020 - # cat /etc/redhat-release CentOS Linux release 7.8.2003 (Core) # yum install -y rh-python38 which # scl enable rh-python38 bash ...Abbreviation
🌐
Reddit
reddit.com › r/redhat › how to add packages to scl
r/redhat on Reddit: How to add packages to SCL
April 22, 2022 -

First time working with SCL so please forgive me. Maybe I'm missing something obvious, I just don't know. I recently deployed an instance of RH8 on AWS. I installed a couple version of Python - Python 3.7 and 3.9.

However when I use the following command I get no results.

root@ip-testmachine : scl list-collections

I thought that by installing the software package yum install <package> it automatically gets added to the SCL manager. Do I have do something else to have them added so I can enable them?

Any help would be appreciated.

🌐
GitHub
gist.github.com › singlecheeze › a36312c590eb1ca33f131203290248f6
vsphere-automation-sdk-python on RHEL 7 · GitHub
$ which python # before scl enable /usr/bin/python $ scl enable rh-python38 bash $ which python /opt/rh/rh-python38/root/usr/bin/python
Find elsewhere
🌐
Red Hat
access.redhat.com › solutions › 1252913
How to use Red Hat Software Collections in scripts and cron jobs - Red Hat Customer Portal
Adjust the script header to use #!/usr/bin/env python as the scripts interpreter definition and setup cron, enabling Red Hat Software Collections 30 * * * * scl enable python27 <path to script>/python_script.py · Call a shell script, which is executing the respective Red Hat Software Collections script and setup a cron job accordingly · #/bin/bash python <path to script>/python_script.py
🌐
Soton
linuxdesktops.soton.ac.uk › softwarecollections.html
Software collections (SCL) — Linux Desktops RHEL7 documentation
Once you have installed an SCL package you must first ‘enable’ its use and run a program with the package enabled. For example: ... This ‘enables’ the rh-python35 package (Python 3.5) and then runs the command bash.
🌐
University of Edinburgh
computing.help.inf.ed.ac.uk › scl
Software Collections | Documentation
One way would be to alias the software, but 'scl enable' uses the shell positional parameters in such a way that an alias confuses things - it looks in the "wrong" place for the name of the software collection. You can use a function, such as function python() { scl enable rh-python36 python ...
🌐
HostAdvice
hostadvice.com › how to › web hosting › centos › how to install python 3 on centos 7 using scl
How To Install Python 3 On CentOS 7 Using SCL
May 31, 2022 - Now to access this version, we should make use of the SCL tool to launch a different shell instance: ... The command above will call /opt/rh/rh-python36/enable; a script that changes the variables of a shell environment.
🌐
Red Hat
developers.redhat.com › blog › 2018 › 08 › 13 › install-python3-rhel
How to install multiple versions of Python on Red Hat Enterprise Linux | Red Hat Developer
February 27, 2024 - There is no scl disable command. Everything is in environment variables, so you can work around the lack of this command, but it would be a manual process. You can, however, enable a different software collection that then takes precedence over the collection in your profile. Using your preferred text editor, add the following line to your ~/.bashrc: # Add RHSCL Python 3 to my login environment source scl_source enable rh-python36
🌐
Austindewey
austindewey.com › 2019 › 03 › 26 › enabling-software-collections-binaries-on-a-docker-image
Enabling Software Collections Binaries On A Docker Image<!-- --> - Austin Dewey
FROM docker.io/centos:7 # Install SCL release package and python SCL RUN yum -y install centos-release-scl && \ yum -y install --setopt=tsflags=nodocs rh-python35 # Enable rh-python scl binary COPY scl_enable /usr/bin/scl_enable ENV BASH_ENV="/usr/bin/scl_enable" \ ENV="/usr/bin/scl_enable" \ PROMPT_COMMAND=".
🌐
Unix.com
unix.com › shell programming and scripting
How to use scl enable python command call with in bash shell script? - Shell Programming and Scripting - Unix Linux Community
January 24, 2019 - I have a bash shell script, within it i am using the below two commands . its failing right on scl enable command itself. if i run it by itself without a shell, it works fine. by default it is using pythin version 2.6 something. i want to use 3.4 version for that reason with in the shell script using below python side calls. need help please how to properly use the below two lines within bash shell script. scl enable rh-python34 python 'excel2csv.py' '-P' 'Khai123' '/usr/local/bin/ltchadoop...
🌐
GitHub
github.com › siliconcompiler › siliconcompiler › blob › main › docs › user_guide › installation.rst
siliconcompiler/docs/user_guide/installation.rst at main · siliconcompiler/siliconcompiler
sudo subscription-manager repos --enable rhel-server-rhscl-7-rpms # enable Red Hat Software Collections repository sudo yum -y install rh-python38 # install Python 3.8 scl enable rh-python38 bash # enable Python in current environment python3 ...
Author   siliconcompiler
🌐
Nethserver
wiki.nethserver.org › doku.php
python-scl [NethServer & NethSecurity]
default is python2.7 python33 is python3.3 python34 is python3.4 python35 is python3.5 python36 is python3.6 python38 is python3.8 · python –version and you can see what is the version · Each rpm must be installed manually, this an example on how to find it · yum list python33\* yum list rh-python34\* yum list rh-python35\* yum list rh-python36\* yum list rh-python38\*
🌐
Red Hat
access.redhat.com › discussions › 702583
Red Hat Customer Portal - Access to 24x7 support and knowledge
October 7, 2016 - I am trying to write python script running on RH 6 using python 2.7 from Software Collections (SCL). Since I couldn't find any way to use shebang with SCL I am trying to use a workaround: run bash script which enables python27 SCL and run python script.