Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change python3 to default in linux mint

I have a little problem with changing python3 to default in newly installed operating system linux Mint 19.3. It was pretty easy on Ubuntu 16.04 but now I need small help here.

So, I run

python --version

and got this

Python 2.7.15+

Than I run

python3 --version

and this was the result

Python 3.6.8

After entering this command

sudo update-alternatives --config python

I received obvious info

update-alternatives: error: no alternatives for python

Both version of python are located in /usr/bin folder. The issue occurs when I'm trying to change python3 to as a default by typing the command

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6

The terminal outputs the following

update-alternatives: --install needs <link> <name> <path> <priority>

Any help here would be welcome.

like image 382
Michał Avatar asked Jan 26 '20 07:01

Michał


People also ask

How to change default version of Python on Linux?

To define python3 as your default version of python on linux, you need to add a specific line to .bashrc file located in your home directory. Here is a simple method to do so through command line interface (termianl). then run python --version to check if the change has applied.

What is the latest version of Python for Linux Mint?

Python 3.9 is the newest release of Python. It is available from the deadsnakes repository and source code. This post explains the Python 3.9 installation on Linux Mint 20.

How to set Python 3 as the default language in Linux?

Which leaves us with no choice other than, explicitly typing python3. However, we can set python3 as default by firing two commands on terminal Now if we check in the terminal by just running the “python” command it would result in the following: The interpreter of python 3 was launched, rather than an interpreter of python2.

How to update Python to the latest version installed on Ubuntu?

If you have followed my article on how to install Python 3.9 on Ubuntu, you will notice that 3.9 is not the version used when running the following command: To update Python to the latest version installed on your system, we can use update-alternatives to change the python shortcut command to point to Python 3.9.


1 Answers

In your case, priority is missing, just append 1 at the end of the command like this :

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
like image 82
Dark Fidis Avatar answered Oct 03 '22 09:10

Dark Fidis