Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing default python to another version

Currently when I use "python" command, it points to python2.6. I have installed python3.1 and I want the "python" command point to python3.1. How it is possible?

mahmood@mpc:~$ which python 
/usr/bin/python
mahmood@mpc:~$ ls -l /usr/bin/python
lrwxrwxrwx 1 root root 9 2010-11-24 16:14 /usr/bin/python -> python2.6
mahmood@mpc:~$ uname -a
Linux orca 2.6.32-24-server #39-Ubuntu SMP Wed Jul 28 06:21:40 UTC 2010 x86_64 GNU/Linux
like image 803
mahmood Avatar asked Nov 27 '22 00:11

mahmood


1 Answers

Since you have Linux, and if you want to simply type "python" instead of "python3" in order to run Python programs, a solution is simply to define an alias in you shell configuration file (.bashrc, etc.). For Bourne shells, it should be something like

alias python=python3

(or whatever your Python 3 name is).

This way, you do not have to change anything on your system, so this solution should quite innocuous and it should not break your system.

like image 67
Eric O Lebigot Avatar answered Nov 29 '22 14:11

Eric O Lebigot