2

I want to execute python from php and I do have a script that works fine for default python interpreter. I have centos with default python 2.6.6 which is installed at /usr/bin/python and python 2.7.3 which is installed at /usr/local/bin/python2.7. You can see what is the default python version:

[root@me ~]# python -V
Python 2.6.6

[root@me ~]# python2.7 -V
Python 2.7.3

How do I make python 2.7.3 default python on my OS. So when i run python -V i should get 2.7.3?

I know it is bad. The alternative is to uninstall python 2.7.3 and I do not know how to do this.

Kenster
  • 23,465
  • 21
  • 80
  • 106
Brana
  • 1,197
  • 3
  • 17
  • 38
  • 2
    1) This is better at super user. 2) You don't want to do that (lots of things may break.) 3) Take a look at virtualenv – OMGtechy Jan 02 '15 at 14:54
  • You can create an alias: `alias python=/path/to/python2.7.3` – fedorqui Jan 02 '15 at 14:56
  • check this similar question. http://stackoverflow.com/questions/19256127/two-versions-of-python-on-linux-how-to-make-2-7-the-default –  Jan 02 '15 at 14:58
  • where do i type this (alias python=/path/to/python2.7.3) and how do i change it to default? – Brana Jan 02 '15 at 14:59
  • You can write it in your shell. Then you can check if it is set by typing `alias`. It will list all the alias you have. To make it permanent, add the line in `~/.bashrc`, so that it is loaded on log in. – fedorqui Jan 02 '15 at 15:30
  • Seconding @OMGtechy's comment. You don't want to do this for the system. The alias is potentially reasonable though but you need to remember that you've done it. – Etan Reisner Jan 02 '15 at 16:34

1 Answers1

1

Execute the below commands to make yum work as well as python2.7

echo "export PATH="/usr/local/bin:$PATH"" >> /etc/profile
source /etc/profile
mv /usr/bin/python /usr/bin/python.bak
update-alternatives --install /usr/bin/python python /usr/bin/python2.6 1
update-alternatives --install /usr/bin/python python /usr/local/bin/python2.7 2
update-alternatives --config python
sed -i "s/python/python2.6/g" /usr/bin/yum
Shahrukh Khan
  • 316
  • 1
  • 3
  • 15