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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to enable rh-python34 from bash shell script, default python is 2.6 version.?
# 1  
Old 03-31-2019
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.
# 2  
Old 03-31-2019
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:
Code:
bash --posix -c 'type python;python --version;printf "%s\n" "$PATH"'

# 3  
Old 03-31-2019
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:;
Code:
scl enable rh-python34 bash

Code:
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)

Last edited by Don Cragun; 03-31-2019 at 07:21 PM.. Reason: Add missing CODE tags.
# 4  
Old 03-31-2019
What output do you get when you run the command:
Code:
scl enable rh-python34 bash <<"EOF"
printf '%s\n' "$PATH"
type python rh-python34
EOF

# 5  
Old 03-31-2019
When i run the command you have provided i am getting this please: thank you.

Code:
[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:
Code:
[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

Code:
[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]$

# 6  
Old 03-31-2019
Do you ever want to use python version 2.6.6 again?

Please show us the output from the commands:
Code:
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

# 7  
Old 03-31-2019
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:
Code:
[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:
Code:
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

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

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... (3 Replies)
Discussion started by: cplusplus1
3 Replies

2. Shell Programming and Scripting

Beginner here, how to call a bash-script from python properly?

Hi everyone, i have the following script.sh: foo='lsusb | grep Webcam | cut -c16-18' sudo /home/user/public/usbreset /dev/bus/usb/001/$foo when i try to call this script from python using subprocess.call("script.sh", shell=True) it seems that only 'sudo /home/user/public/usbreset' is being... (6 Replies)
Discussion started by: hilfemir
6 Replies

3. Shell Programming and Scripting

Enable logging from within the shell script

Bash on Oracle Linux 6.3 I have a shell script whose output I want to redict to a log file. So, I can simply redirect the output as shown below. # cat myscript.sh #### I actually want some logging mechanism here which will redirect the output to a log file echo 'hello world' #... (3 Replies)
Discussion started by: John K
3 Replies

4. Shell Programming and Scripting

Unable to store "python --version" to a shell variable

Hi All, I need to get the version of python installed and store it in a variable for later use. Whereas it is printing on the console instead of storing to variable. I am able to store output of ls command in a variable. Please check the below code : root@myhost:/volumes/srini# cat... (4 Replies)
Discussion started by: srinivasan.neel
4 Replies

5. Shell Programming and Scripting

[Solved] Unable to call a python script from bash

Hi, I am trying to run a python script embedded in bash script. But is throwing me an error. Please help. Script: #!/bin/bash nohup /usr/bin/python /opt/web/http.py & Error: /usr/bin/python: can't open file '/opt/web/http.py': No such file or directory Please help me on this. (6 Replies)
Discussion started by: maddy26615
6 Replies

6. SuSE

"ssh suse-server 'python -V' > python-version.out" not redirecting

Okay, so I have had this problem on openSUSE, and Debian systems now and I am hoping for a little help. I think it has something to do with Python but I couldn't find a proper Python area here. I am trying to redirect the output of "ssh suse-server 'python -V'" to a file. It seems that no matter... (3 Replies)
Discussion started by: Druonysus
3 Replies

7. Shell Programming and Scripting

Python call to bash script returns empty string

Hi all, I need help figuring out why my script won't work when envoked from web interface. First off, I'm fairly new to Linux and Shell scripting so, my apologies for being ignorant! So I have a python script that I envoke through a web interface. This script envokes my shell script and... (8 Replies)
Discussion started by: arod291
8 Replies

8. Programming

Python: bash-shell-like less functionality in the python shell

Hello, Is there some type of functional way to read things in the Python shell interpreter similar to less or more in the bash (and other) command line shells? Example: >>> import subprocess >>> help(subprocess) ... ... I'm hoping so as I hate scrolling and love how less works with... (0 Replies)
Discussion started by: Narnie
0 Replies

9. Shell Programming and Scripting

how to disable and enable <control>-c or -z in a shell script

Dear all, good day. i'm asking about how to disable <control>-c or <control>-z in the beginning of a shell script then enable it again before the script exit Best Regards ---------- Post updated at 04:41 AM ---------- Previous update was at 04:18 AM ---------- Dear All i found the... (3 Replies)
Discussion started by: islam.said
3 Replies

10. Red Hat

enable FTP access / check version

how can I check the Linux version? (14 Replies)
Discussion started by: zp523444
14 Replies
Login or Register to Ask a Question