I updated my system (Ubuntu 18.04) from Python 3.6 to Python 3.8, and reset the defaults so that python3 now points to Python 3.8 (and not 3.6). However, since then, the terminal has refused to open using Ctrl + Alt + T, and other obvious methods such as clicking on the icon itself.
When I run gnome-terminal
- I get the following:
usernew@HP:/usr/lib/python3/dist-packages/gi$ gnome-terminal
Traceback (most recent call last):
File "/usr/bin/gnome-terminal", line 9, in <module>
from gi.repository import GLib, Gio
File "/usr/lib/python3/dist-packages/gi/__init__.py", line 42, in <module>
from . import _gi
ImportError: cannot import name '_gi' from partially initialized module 'gi' (most likely due to a circular import) (/usr/lib/python3/dist-packages/gi/__init__.py)
I don't know what this means but I guess it definitely points to the fact that something went wrong during the update. I understand that there are other existing threads on similar issues, but most of them were about updating from Python2 to Python3, so I'm not sure if they're relevant.
Could someone help, please?
Important Update:
So, after reading this answer - I changed the gnome-terminal
script's first line to #!/usr/bin/python3.6
instead of #!/usr/bin/python3.8
- and that solves the problem.
Also, when I type python3
in the terminal, I'm greeted with Python 3.8.2, as desired.
The question remains - Why did this work? What was the actual problem? An explanation would help, so I really know what I'm doing.
Thanks!
Navigate to Control Panel. Click “Uninstall a program”, and a list of all the currently installed programs will display. Select the Python version that you want to uninstall, then click the “Uninstall” button above the list – this has to be done for every Python version installed on the system.
Terminal is not opening in UbuntuIf your GUI desktop is frozen and the terminal won't open, you might try to open the TTY console. To do so, enter the following shortcut CTRL + ALT + F3 . To return back to your GUI Desktop enter ALT + F2 shortcut.
You shouldn't change the symlink /usr/bin/python3
since a bunch of Ubuntu components depend on it, and Ubuntu-specific Python libraries like gi
are built only for the Python build shipped with Ubuntu, which is version 3.6 on 18.04.
See Gnome terminal will not start on Ask Ubuntu (though note that it's about Ubuntu 16.04 which uses Python 3.5). So the best way to fix it is to revert the symlink:
sudo ln -sf python3.6 /usr/bin/python3
As for setting Python 3.8 as the default, you could put an alias in your bashrc:
alias python3=python3.8
But this will only affect the shell for your user. In scripts for example if you want to use Python 3.8 you'll have to write it, i.e. #!/usr/bin/env python3.8
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With