MJimitater
MJimitater

Reputation: 939

How can we link python2 to python?

Some time ago I used

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10

to simply write python for having python3.

I noticed this alias breaks the package manager in some cases, so Im trying to revert this. I used

sudo update-alternatives --remove-all python

to remove this. But now I want to go back to default, meaning writing python calls python2 and only python3 calls python3.

Any idea how we can do this?

Cheers

EDIT:

By running

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 10

I managed to link python2 to python and leaving python3 as it. is. Is this the proper way of fixing it? It doesn't seem like it...

EDIT2:

I just upgraded my system from 19.10. to 20.04., I have no problems anymore regarding broken packages, but this was probably the easy-way-out, I'd still appreciate a reasonable thought about how to resolve these python links well.

Funny though, I thought python2 is not used anymore in 20.04., but if I type python then python2 is called again.. how?

Upvotes: 1

Views: 217

Answers (1)

Daniel Connelly
Daniel Connelly

Reputation: 206

There is a good answer to this question on one of the sister sites, which essentially says to create an alias in a bash file (e.g., .bashrc).

The reason python is still installed in the OS is likely because people & programs still use it, though as Adam mentions it isn't maintained. Corroboration that it comes packaged in Ubuntu 20.04 and the program to change this without just changing a bash file (python-is-python3) is in this answer.

Upvotes: 1

Related Questions