0

I'm running Ubuntu 18.04.4 LTS and encountered an issue where after updating my Python from 3.6 to 3.7.5 my terminal keyboard shortcut stopped working and clicking on the terminal icon wouldn't get it to run.

I found a solution on StackExchange but I have no idea why it worked and I would love to understand why. You can find the link below and the solution was

This way the upgrade to 3.7 is useless. You should edit the gnome-terminal file:

Open a terminal and issue the following commands:

cd /usr/bin
sudo nano gnome-terminal
Change #!/usr/bin/python3 to #!/usr/bin/python3.6.

This way you can still use the power of 3.7 and solve the issue with the terminal.

Could anyone try to explain what happened when I did this and why it worked? Would love to know for when I need to upgrade it again! Thank you!

Source: Terminal not opening up after upgrading python to 3.7

2 Answers2

1

If you followed the upgrade path from the linked question, all you did is make the symlink /usr/bin/python3 point to python 3.7 instead of python 3.6.

The line you changed is called a "shebang" line. It tells the kernel which application to use to interpret the file.

Applications from Ubuntu repositories expect /usr/bin/python3 to be python 3.6 and may be incompatible with python 3.7.

So apparently, gnome-terminal is incompatible with 3.7 and if you change the shebang to explicitly point to 3.6 it works again.

You are not supposed to change the default python version, which is evident in the fact that it is not installed in debian alternatives by default. I'd recommend changing it back to 3.6 because there are probably a lot of other applications that won't work.

Instead of changing /usr/bin/python3, use /usr/bin/python3.7 on the command line or in shebang lines of your own python modules.

danzel
  • 6,533
-1

I had upgraded to python 3.10.9 from python 3.8 using deadsnakes repo https://hackersandslackers.com/multiple-python-versions-ubuntu-20-04/

After a while Ubuntu system got restarted, I found out my terminal is messed up & could not open.

Then, I ran this command which basically regenerted locales. This will take a while to complete.

sudo locale-gen --purge

Then I tried opening gnome-terminal & I was able to open the terminal by using latest python version.

Hope this solution helps!