Score:0

How to change python3 path pointer?

cn flag

I am using Ubuntu 20.04.2 LTS with python version 3.9.5 installed.

When I type which python in the terminal, it shows /usr/bin/python which is the default path for python2 (2.7 in my case). But when I type which python3, it shows /usr/local/bin/python3, not the usual default path (/usr/bin/python3) for python3.

I've checked my /usr/bin folder and I did notice that there are files named python3 and python3.9. I just want my python3 path variable to point to the location /usr/bin/python3 or /usr/bin/python3.9. What steps should I take to do that?

P.S., I don't want to set default python to python3, of which instructions I found in the ask-ubuntu forum and also in many articles after some googling. I just want to set my python3 path to /usr/bin/python3 or /usr/bin/python3.9

oldfred avatar
cn flag
DO NOT change default python3, My 20.04 shows `ls -l /usr/bin/python* ` : `/usr/bin/python3 -> python3.8 ` Ubuntu uses that version and change of version will break Ubuntu. Years ago only fix was total reinstall. Now it may be repaired if you have live installer and can chroot back into system to reset to correct python. You can install as many other python versions as you want but have to specifically refer to them.
Score:2
cn flag

As long as a custom python3 is installed in /usr/local/bin/, it will show up as the default python3 executable. why? Because by default, /usr/local/bin/ is listed earlier in the search path then /usr/bin. This way, your custom executables have priority over these installed by the system.

To make the system find /usr/bin/python3 first, you must move out /usr/local/bin/python3. The alternative would be to ticker with your PATH, moving /usr/local/bin behind, but that would affect every other custom executable.

Thus, rename /usr/local/bin/python3 to /usr/local/bin/python3cust or something. Then, you will be using the default python version.

On Ubuntu, you actually may not change the default python version. Python is extensively used in the operating system. Changing the version will likely break things.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.