Reputation: 199
I want to use python 2.7 by deafult in Redhat 6.7 distro to run my scripts currently the distro is having python 2.6 by default which I dont want to use. So far what I have done :
changed the etc/bashrc file and added the path
export PATH="/usr/local/bin:$PATH"
after this when I type python it shows me the same old 2.6 version and scripts fail to run which has to be run using 2.7 version. When i call my python it should show me 2.7 and scripts should automatically take that version to run.
For ex:- I want to run a simple script which will print the data from an api url
import urllib
import json
url = 'www.jamesst/api.com'
data = json.load(urllib.urlopen(url))
print data
This cannot be run in ver 2.6 it requires 2.7 if any alternative is there for code itself, kindly share the same.
Any help would be great.
Upvotes: 0
Views: 2853
Reputation: 372
You can use the alternatives
utility in order to use python27 as your default python using the following steps:
update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
This command will add python to alternatives and make python27 your default python's version.
Upvotes: 0
Reputation: 546
Use the Red Hat Software Collections (SCL) version of Python 2.7. SCL install alongside the original 2.6 version so it won't mess with the OS. There's a simple "SCL enable" command and then they usual yum install. Then follow the docs so that 2.7 is default for your apps.
Upvotes: 1