i have both 2.7 as well as 3.6.5 installed , at first in ubuntu 18.04 the only python version available was 3.6 but after i installed numpy package, along with it 2.7 got installed as well and it turned into default. Is there any solution so as to make 3.6 the default one instead of 2.7??
Asked
Active
Viewed 1.8k times
4
-
3I've recommended to not uninstall python2.7 from Ubuntu because Ubuntu's kernel uses it. – MasOOd.KamYab May 05 '18 at 05:47
-
Open .bashrc file `nano ~/.bashrc`. Type `alias python=python3` on to a new line at the top of the file then save and close the file with `ctrl+o` and `ctrl+x`. – chinmayan May 05 '18 at 05:49
-
@chinmayan you should make your comment an answer. – Max von Hippel May 05 '18 at 05:50
-
Possible duplicate of [Unable to set default python version to python3 in ubuntu](https://stackoverflow.com/questions/41986507/unable-to-set-default-python-version-to-python3-in-ubuntu) – Max von Hippel May 05 '18 at 05:51
-
1Okay will do, @MaxvonHippel :) – chinmayan May 05 '18 at 05:53
-
@UTK007 if one of the answers solves the problem for you, please click the green check-mark to mark it as correct. – Max von Hippel May 05 '18 at 05:56
-
File Name to Write: /home/utkarsh/.bashrc ^G Get Help M-D DOS Format M-A Append M-B Backup File ^C Cancel M-M Mac Format M-P Prepend ^T To Files............what do i need to select out of these??? @chinmayan – UTK007 May 05 '18 at 15:04
2 Answers
17
Open .bashrc file nano ~/.bashrc
. Type alias python=python3
on to a new line at the top of the file then save and close the file with ctrl+o
and ctrl+x
.

chinmayan
- 1,304
- 14
- 13
3
I set python 3 version as default using the following commands:
- Check python version on terminal -
python --version
- Get root user privileges. On terminal type -
sudo su
- If needed write down the root user password.
- Execute this command to switch to python 3.6.
update-alternatives --install /usr/bin/python python /usr/bin/python3 1
- Check python version -
python --version
- Write
exit
to exit the root mode

Laetitia
- 31
- 2