14

For some reason, I can't open the terminal through the shortcut (terminal icon) in Ubuntu 22.04. It works through Visual Studio Code, though, so that makes me confused. I tried using the F keys, but they are only working to the fn functions (such as controlling the brightness). I am not very knowledgeable on how Ubuntu works, so I am terribly confused.

I did try (unsuccesfully) to change my python version to 3.11.

Edit: The contents of /usr/share/applications/org.gnome.Terminal.desktop:

[Desktop Entry]
Name=Terminal
Comment=Use the command line
Keywords=shell;prompt;command;commandline;cmd;
TryExec=gnome-terminal
Exec=gnome-terminal
Icon=org.gnome.Terminal
Type=Application
Categories=GNOME;GTK;System;TerminalEmulator;
StartupNotify=true
StartupWMClass=Gnome-terminal
X-GNOME-SingleWindow=false
OnlyShowIn=GNOME;Unity;
Actions=new-window;preferences;
X-Ubuntu-Gettext-Domain=gnome-terminal

[Desktop Action new-window] Name=New Window Exec=gnome-terminal --window

[Desktop Action preferences] Name=Preferences Exec=gnome-terminal --preferences

Archisman Panigrahi
  • 28,338
  • 18
  • 105
  • 212
  • 2
    By any chance, did you change the default python version? – Archisman Panigrahi Nov 28 '22 at 23:04
  • 1
    oh, I mistook 'python' for 'linux'. I did try (unsuccesfully) to change my python version to 3.11; – user480840 Nov 28 '22 at 23:13
  • 1
    @ArchismanPanigrahi, do you know what the problem could be, given the new information? – user480840 Nov 29 '22 at 20:10
  • 3
    Changing the default python version is bound to cause a lot of problems, for example see https://askubuntu.com/questions/1223013/i-accidentally-removed-python-from-ubuntu-graphical-interface-gone. If the already posted answer does not work for you, you will probably have to reinstall Ubuntu – Archisman Panigrahi Nov 29 '22 at 23:55
  • 1
    You should be able to open xterm. It's hideous by default but you should be able to make any changes you need. – MDeBusk Nov 30 '22 at 02:05
  • Duplicate of https://askubuntu.com/questions/1397938/terminal-not-opening-after-changing-python-version/1397940#1397940 – Archisman Panigrahi Dec 03 '22 at 19:33

6 Answers6

17

If you try to change your python version in a linux distro, it will most certainly cripple your environment. Python is an integral part and may not be changed under any circumstances. There are many questions & answers about it in this forum.

What could you do?

Depending on how you installed it, try to remove every remnant of your python 3.11.x and install the origin python from the repos.

Since you cannot open terminal, open a virtual terminal with ctrl + alt + f3 and login with your username and password.

If your "orignal" version was not removed, you may tell the system to use it again:

sudo update-alternatives --config python3

Select the Version 3.10.6, if provided.

If the alternatives group was removed, that will not work. Try this command:

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
sudo update-alternatives --config python3

If all else fails you may need to reinstall Ubuntu.

What if you need another python version?

There are many possible ways to install any python version in a special environment like "pipenv", "anaconda", "venv", you name it. See here for a small overview of virtual environments.

The current python version in Ubuntu 22.04 ist 3.10.6 as of today.

Tony
  • 103
kanehekili
  • 6,402
6

Had a similar issue, a youtube video resolved my case, without using any cmd line. Go to settings -> Language&Settings -> Change English (United States) to English (Canada) then restart.

Inno
  • 61
  • 1
    I change languages as this comment, restart and it work – Tung Vo Sep 10 '23 at 02:52
  • I was able to solve the problem for me with Inno's Answer. After switching to "English (Canada)" I was able to switch back to "English (United States)" with the same procedure and it still works. – Twistios_Player Oct 27 '23 at 22:09
  • I actually just did a simple reboot and it fixed it too. Curious to hear if there are any reasons why the language change should have any effect here. – Niko Fohr Dec 08 '23 at 06:57
0

For me it was Default Locales.

nano /etc/default/locales

Remove lines that have "LC" or just delete all lines. Reboot.

SamTzu
  • 91
0

I had to update my locale settings in ubuntu:

sudo update-locale LANG=de_DE.UTF-8 LC_MESSAGES=POSIX

Maybe you have to renew your locales or set it to your country.

Andy
  • 1
0

I had the same issue after my auto-update re-installed memory-hog useless Snap again. I've never used evil Snap, and I've purged it from my system many times.

Also the same update made changes in the Settings > Region & Languages > Language => UNSPECIFIED.

That is the root of the problem! Thanks to Inno. (the auto-update has also changed Python version too :)

The solution was simple and obvious: set my language - English(US) and restart.

All my time-wasting attempts to sudo apt install --reinstall gnome-terminal and set Python version were unsuccessful.

somoso
  • 666
-1

I had a similar issue. I tried a bunch of things everywhere. Here's what I eventually found that worked. It turned out when I updated python, it updated what gnome-terminal was set to. Here's what ya do:

Ctrl + Alt + F3, this will open a terminal

login

type sudo vim /usr/bin/gnome-terminal substitute vim for whatever editor you have if needed

check the comment at the top does it read #!/usr/bin/python3? If so, change it to the version you're using of python.

I was updating to 3.9 so I changed it to #!/usr/bin/python3.9. This fixed the issue and allowed me to open the terminal.

The issue was caused by when I updated python, for some reason it changed the gnome-terminal to just generically be python, instead of the python version I was actually using.

  • generic "python3" is symlinked to the system version of Python. Updating your version of Python messed with that, not with the shebang in gnome terminal. Something is still very broken with your system if the programs that are included in the OS can't run using the default python. Follow the other answer here to fix it. – Esther Apr 20 '23 at 17:50