Score:-4

Ubuntu default python3.8.10

bi flag

When I install python3.9 or 3.10, there is no change in python3 command. It is still python3.8.10 and all packages will be installed for 3.8.10 unless I run a python3.9 -m pip. What is the reason that you cannot change python3 version to a newer one?

cocomac avatar
cn flag
Because it will break Ubuntu if you replace the old one completely. Ubuntu is very picky about which version of Python is the default. See [this question](https://askubuntu.com/questions/1132349/terminal-not-opening-up-after-upgrading-python-to-3-7) and [this one](https://askubuntu.com/q/384033/1438484), too. As to _why_ it is so picky, I don't know.
guiverc avatar
cn flag
Many Ubuntu tools rely on `python3` and work with the version the system comes with. If you change the *default* version, those Ubuntu tools may cease working, or may cease working reliably, thus protections on keeping the default version correct. You didn't say if desktop or server, but you should avoid making changes to the default python3 unless you're fully aware of those consequences.
mchid avatar
bo flag
The OS depends on the standard python version. However, you can set an alias for your user as mentioned below. Don't forget to log out and back in after you set the alias or run `source ~/.bashrc` to apply the changes.
us flag
Don't mess up with the default python version. If something goes wrong, you may have to reinstall Ubuntu. Use Anaconda/Miniconda instead. It will set up an isolated python environment for you. https://www.anaconda.com/products/individual, https://docs.conda.io/en/latest/miniconda.html
Score:-1
cn flag

The reason you cannot change python3 to a newer default version is because it would break the operating system and many applications that depend on the default version of python3. You can, however, use an alias so that, when you run the python command in the terminal, python3.9 will execute.

Open the bashrc file by using the following command:

nano ~/.bashrc

Add the following line to the below of the bashrc file .

alias python3='/usr/bin/python3.9'

After you save the file, run the following command to apply the changes:

. ~/.bashrc
mchid avatar
bo flag
People may want to explain the downvotes to the author. Simply setting this as an alias is a safe alternative recommended by many other upvoted answers on other similar questions. If you have a problem running the command with `sudo` I suggest you ask a separate question or leave a comment because there is a fix for that and it has nothing to do with `python`. It's not typically recommended to install `pip` packages system wide anyhow.
mchid avatar
bo flag
If you want to install pip for python 3.9, you can use [this answer](https://askubuntu.com/questions/1331391/how-do-you-install-pip-for-python3-9-4?rq=1). However, the OP wasn't asking that so we cannot assume they are ignorant of this.
JerryWill321 avatar
us flag
The default Python version used for script execution can be changed, but it cannot be changed system-wide (mentioned in previous comment) because certain components of Ubuntu depend on specific Python installations.
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.