Hi, today’s post will be very short. Recently I found out that there is a strange bug related to Python version upgrade. My terminal stopped working after I upgraded Python version from 3.10 to 3.11 on Ubuntu 22.04. Not only terminal, but also other preinstalled applications like „Software Updater”. I decided to write a short article about this, first to warn you and second to give you a quick fix.
Actually, it took me a while to connect these two events because I was running Ubuntu in a virtual machine and connecting via ssh from a Visual Studio Code terminal running on a Windows host. But eventually I had to open the Ubuntu terminal and found that it wouldn’t start. I haven’t looked into why such a problem occurs, but it looks like these applications are not compatible with newer Python versions, so the best thing to do is to revert to the previous version. You don’t have to remove python3.11. You can still use it, but do so in a virtual environment and use the old version as the default.
The problem is how to change the Python version when there is no terminal available. There are a few solutions. First, if you can connect from the outside using ssh, that’s the quickest solution. The second option is to use a virtual terminal with these shortcuts:
Another option is to download different terminal application. You don’t have to use GNOME Terminal, which comes with Ubuntu by default. There are many alternative terminal applications that you can install for different features, aesthetics, and use cases. Here are some popular options, choose the one that works best for you:
sudo apt install alacritty
sudo apt install terminator
sudo apt install tilix
sudo apt install kitty
sudo apt install konsole
sudo apt install guake
sudo apt install yakuake
Once you have successfully run an alternate terminal and now have access to the shell, all you need to do is tell the system that you want to use a different version of Python.
sudo update-alternatives --config python3
If switching to the Alternatives group does not work for you, it has been removed. You need to reinstall it with the following command and then run the previous one again
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
Try it now, your old terminal should work. You don’t even have to reboot your computer.