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.

Was it helpful?

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top