Edited
New Answer
I found a better way to install your preferred python
version. It's more stable and more secure than using ppa:deadsnakes/ppa
repository.
Sure now this is not a direct answer to the problem you had anymore. But I am editing this answer here in hope to help you and anyone that may want to install python3.10
in a machine that does not come with it installed by default.
You can use asdf, which is a tool version manager. With it you may install any python version you want, independent of your OS. It is gonna be more verbose, but works perfectly well, without any conflict with some pre-installed python
version.
To avoid problems when installing asdf
and python
, install the following packages:
sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev
Then run:
sudo apt update && sudo apt upgrade
to make sure everything is up to date.
Installing asdf
To install asdf
, first we clone from the repository and the branch of asdf
version we want (Please note that the version specified in the end of the command may change. I just followed the documentation):
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.0
Now you only got to add a few lines to the end of your script configuration file. It may change according to your shell, but again, check the documentation for specific instructions (including zsh
).
To find out what kind of terminal you're using, you can run:
echo $SHELL
If your're using bash
then you can add the following to the end of your ~/.bashrc
(yes, the dots are included):
. $HOME/.asdf/asdf.sh
. $HOME/.asdf/completions/asdf.bash
After that, you just have to restart your terminal.
Installing python3.10 (or any version you want)
Now with asdf
installed, you should install a plugin to manage multiple python
versions. To do that, just run the command:
asdf plugin-add python
To globally install python3.10.4
in your system, run:
asdf install python 3.10.4
And then:
asdf global python 3.10.4
Lastly, run:
asdf reshim
This last command is a somewhat refresh for asdf
to work properly after globally installing libraries. Run it whenever you install something with asdf
, just to be sure.
No need to worry about running this command after installing some package or module with pip though (well, at least I never had).
Credits to Kenzie Academy. Learned it there.
Old Answer
I ran exactly into the same problem. I found the answer here.
At first, I tried to simply open the gnome-terminal
file without a terminal and change it, but it didn't work, because using a GUI I had no sudo permissions. So the workaround that worked for me and I expect that may work for you, was to open the file with VSCode and then used the VSCode integrated terminal to run the following command:
sudo nano /usr/bin/gnome-terminal
Of course you don't have to use nano
, you could use vim
or something else. Anyway, once there, you can change the first line of the file, which is a comment, from
#!/usr/bin/python3
to
#!/usr/bin/python3.8
Ubuntu 20.04 is well compatible with python3.8
, so that's why I suggested you putting python3.8
there but you could surely test if some other version works.
This is not a way to go back to python3.8
. You will still have the add-ons of python3.10
.
Python2.6
too:--install /usr/bin/python python /usr/bin/python2.6 10
? – WrungPython2.6
so that can be uninstalled, why did you follow the instructions word for word? you had to adjust and not install 2.6. why the terminal doesn't open? no idea – Wrungpipenv
. – Joni