How to enable rh-python34 from bash shell script, default python is 2.6 version.?

On our server default python version is 2.6, how to enable rh-python34 via bash shell.
Thanks a lot for the helpful info.

What operating system is your server running?

Has rh-python34 been installed on your server? If so, in what directory was it installed?

What is the name of the utility in rh-python34 that you want to execute? (Is it python or is it rh-python34 ?)

What output do you get when you run the command:

bash --posix -c 'type python;python --version;printf "%s\n" "$PATH"'

Thanks a lot for the reply, when i execute the command i am getting the following please, by default it is 2.6.6, i do have some python scripts that extracts xlsx files into csv and does some tweaking of data. for which 2.6.6 version doesn't work. for that reason i run the below command, that way it enables 3.4. but i want to have a script within my bash to invoke enable this version:;

scl enable rh-python34 bash
python is /usr/bin/python
Python 2.6.6
/opt/cloudera/parcels/CDH/lib/hive/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/puppetlabs/bin

--- Post updated at 05:03 PM ---

here is the version of red hat please:
Red Hat Enterprise Linux Server release 6.9 (Santiago)

What output do you get when you run the command:

scl enable rh-python34 bash <<"EOF"
printf '%s\n' "$PATH"
type python rh-python34
EOF

When i run the command you have provided i am getting this please: thank you.

[rreddy@svrhdpm01 ~]$ scl enable rh-python34 bash <<"EOF"
> printf '%s\n' "$PATH"
> type python rh-python34
> EOF
/opt/rh/rh-python34/root/usr/bin:/opt/cloudera/parcels/CDH/lib/hive/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/puppetlabs/bin
python is /opt/rh/rh-python34/root/usr/bin/python
bash: line 2: type: rh-python34: not found
[rreddy@svrhdpm01 ~]$

--- Post updated at 06:23 PM ---

when i do the following i get this:

[rreddy@svrhdpm01 ~]$ python3 -V
Python 3.6.3

--- Post updated at 06:47 PM ---

I ran the following commands and got the following paths to python3.4
If i do the scl command like below the basj shell script calling .py file works fine, but i want to automate, that way from within the script somehow the scl command enables 3.4 version. thank you

[rreddy@svrhdpm01 bin]$ scl enable rh-python34 bash
[rreddy@svrhdpm01 bin]$ python -c "import sys; print(':'.join(x for x in sys.path if x))"
/opt/rh/rh-python34/root/usr/lib64/python34.zip:/opt/rh/rh-python34/root/usr/lib64/python3.4:/opt/rh/rh-python34/root/usr/lib64/python3.4/plat-linux:/opt/rh/rh-python34/root/usr/lib64/python3.4/lib-dynload:/opt/rh/rh-python34/root/usr/lib64/python3.4/site-packages:/opt/rh/rh-python34/root/usr/lib/python3.4/site-packages
[rreddy@svrhdpm01 bin]$

Do you ever want to use python version 2.6.6 again?

Please show us the output from the commands:

ls -l /opt/rh/rh-python34/root/usr/bin
/opt/rh/rh-python34/root/usr/bin/python --version
type python2 python3
python2 --version
python3 --version

This is Hadoop cluster, master node. this was installed by admins, i am just a developer on hadoop. some of the scripts of ETL are developed on python which works with python 3.4 version uses xl based libraries.

i ran the commands you provided i see the following:

[rreddy@svrhdpm01 bin]$ /opt/rh/rh-python34/root/usr/bin/python --version
/opt/rh/rh-python34/root/usr/bin/python: error while loading shared libraries: libpython3.4m.so.rh-python34-1.0: cannot open shared object file: No such file or directory
[rreddy@svrhdpm01 bin]$ python2 --version
Python 2.6.6
[rreddy@svrhdpm01 bin]$ python3 --version
Python 3.6.3
[rreddy@svrhdpm01 bin]$

--- Post updated at 07:34 PM ---

I was reading some tips on net and found the following example, using or referencing a specifc version of python vai bash shell script: may be this logic can be used ,
in my shell script i call the following
, not sure how exactly i could use this example please:
python 'excel2csv.py' 'myvalue123' $PROCESS_DIR $TEMP_DIR $LOG_FILE

Example:

https://stackoverflow.com/questions/16631461/scl-enable-python27-bash

#!/bin/bash
cd /var/www/python/scripts/
source /opt/rh/python27/enable
python runAllUpserts.py >/dev/null 2>&1

I asked for three things last time that you have not answered:

Please show us the output from the commands:

ls -l /opt/rh/rh-python34/root/usr/bin
type python2 python3

And, since python3 seems to be version 3.6.3 (not 3.4) and the python enabled by the command scl enable rh-python34 bash doesn't seem to work on its own, I'm confused about what is going on. Please also show us the output from:

scl enable rh-python34 bash <<"EOF"
python --version
EOF

Is there some reason why you cannot just use python3 instead of python when you want to use rh-python34 ? Have you tried your scripts with it to see if it works?