Always run python 2.6 instead of 3.4 in centos
Question
I have installed python 3.4 in centos. So I opened terminal and typed python or idle then always ran python 2.6 not python 3.4. How can i run python 3.4 instead of 2.6? thanks you.
Solution
Do not replace the default Python! CentOS's system tools such as yum, system-config-* tools and several other things rely on the default Python 2.6 installation. Set up a virtual environment instead, where you can define which is the default version.
virtualenv --python=/usr/bin/python3.4 myenviron
source myenviron/bin/activate
OTHER TIPS
First, look for where your Python 3.4 is located:
$ which python3.4
/usr/bin/python3.4
See if ~/bin (e.g., /home/username/bin) directory is in the PATH environment variable:
$ echo $PATH
/home/username/bin:/usr/local/bin:/usr/bin:/bin
If not, add the bin directory to PATH, ideally within your ~/.bashrc file. Then create a symlink pointing to the Python interpreter under the bin directory:
$ ln -s /usr/bin/python3.4 /home/username/bin/python
This way, when you type python
on the command line, the interpreter specified will be launched.
I am on Debian/Wheezy, so the detail might be slightly different, but a similar approach should work.