Ubuntu – 18.04–GnomeTerminal won’t start

command linegnome-terminalpython

When I run gnome-terminal from Xterm I get:

File "/usr/lib/python3/dist-packages/gi/init.py", line 42, in
from . import _gi
ImportError: cannot import name '_gi' from 'gi' (/usr/lib/python3/dist-packages/gi/init.py)

I've already tried:

sudo rm /usr/bin/python3
sudo ln -s python3.5 /usr/bin/python3
sudo apt-get install python3-gi
sudo apt install python3.5

I also reinstalled the terminal, yet nothing has worked.

Python output: 
>> import gi
>> gi.__file__
>> '/usr/lib/python3/dist-packages/gi/__init__.py'

Gnome terminal will not start
Your python3 install is corrupted
Terminal and Software update crash on open, python installation related

-rwxr-xr-x  1 root root        3452 Jul 19  2017 activate-global-python-argcomplete3
lrwxrwxrwx  1 root root          26 Mar 26  2018 dh_pypy -> ../share/dh-python/dh_pypy
-rwxr-xr-x  1 root root        1056 Apr 16  2018 dh_python2
lrwxrwxrwx  1 root root          29 Mar 26  2018 dh_python3 -> ../share/dh-python/dh_python3
lrwxrwxrwx  1 root root          23 Nov 12 09:31 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx  1 root root          23 Aug  3 20:54 pdb3.5 -> ../lib/python3.5/pdb.py
lrwxrwxrwx  1 root root          23 Oct 22 07:32 pdb3.6 -> ../lib/python3.6/pdb.py
-rwxr-xr-x  1 root root       88224 Dec 17  2017 pvtkpython
lrwxrwxrwx  1 root root          31 Oct 25 07:11 py3versions -> ../share/python3/py3versions.py
lrwxrwxrwx  1 root root          26 Mar 26  2018 pybuild -> ../share/dh-python/pybuild
lrwxrwxrwx  1 root root          18 Dec 30 16:08 python -> /usr/bin/python3.6
lrwxrwxrwx  1 root root           9 Apr 16  2018 python2 -> python2.7
-rwxr-xr-x  1 root root     3670448 Nov 12 09:31 python2.7
lrwxrwxrwx  1 root root          33 Nov 12 09:31 python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root root          16 Apr 16  2018 python2-config -> python2.7-config
-rwxr-xr-x  1 root root         365 Aug 22  2016 python2-qr
lrwxrwxrwx  1 root root          18 Dec 30 16:12 python3 -> /usr/bin/python3.5
-rwxr-xr-x  2 root root     4117024 Aug  3 20:54 python3.5
lrwxrwxrwx  1 root root          33 Aug  3 20:54 python3.5-config -> x86_64-linux-gnu-python3.5-config
-rwxr-xr-x  2 root root     4117024 Aug  3 20:54 python3.5m
lrwxrwxrwx  1 root root          34 Aug  3 20:54 python3.5m-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x  2 root root     4522328 Oct 22 07:32 python3.6
lrwxrwxrwx  1 root root          33 Oct 22 07:32 python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x  1 root root         401 Feb 21  2018 python3.6-coverage
-rwxr-xr-x  2 root root     4522328 Oct 22 07:32 python3.6m
lrwxrwxrwx  1 root root          34 Oct 22 07:32 python3.6m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx  1 root root          16 Oct 25 07:11 python3-config -> python3.6-config
-rwxr-xr-x  1 root root         397 Feb 21  2018 python3-coverage
lrwxrwxrwx  1 root root          10 Oct 25 07:11 python3m -> python3.6m
lrwxrwxrwx  1 root root          17 Oct 25 07:11 python3m-config -> python3.6m-config
-rwxr-xr-x  1 root root        2555 Jul 19  2017 python-argcomplete-check-easy-install-script3
-rwxr-xr-x  1 root root         314 Jul 19  2017 python-argcomplete-tcsh3
lrwxrwxrwx  1 root root          16 Apr 16  2018 python-config -> python2.7-config
lrwxrwxrwx  1 root root          29 Apr 16  2018 pyversions -> ../share/python/pyversions.py
-rwxr-xr-x  1 root root        2665 Jul 19  2017 register-python-argcomplete3
-rwxr-xr-x  1 root root       14424 Dec 17  2017 vtk6python
-rwxr-xr-x  1 root root        2975 Nov 12 09:31 x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root root          34 Aug  3 20:54 x86_64-linux-gnu-python3.5-config -> x86_64-linux-gnu-python3.5m-config
-rwxr-xr-x  1 root root        3246 Aug  3 20:54 x86_64-linux-gnu-python3.5m-config
lrwxrwxrwx  1 root root          34 Oct 22 07:32 x86_64-linux-gnu-python3.6-config -> x86_64-linux-gnu-python3.6m-config
-rwxr-xr-x  1 root root        3283 Oct 22 07:32 x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx  1 root root          33 Oct 25 07:11 x86_64-linux-gnu-python3-config -> x86_64-linux-gnu-python3.6-config
lrwxrwxrwx  1 root root          34 Oct 25 07:11 x86_64-linux-gnu-python3m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx  1 root root          33 Apr 16  2018 x86_64-linux-gnu-python-config -> x86_64-linux-gnu-python2.7-config

Best Answer

Before issuing above like commands always keep notes on what the release was prior ... so before issuing this

sudo rm /usr/bin/python3

you should make a note of what release is the default by issuing

python3 --version

which on ubuntu 18.10 shows

Python 3.6.7

now you need to investigate what a bog standard 18.04 was using and put it back ... without knowing that you can see what python releases your box has by issuing

which python
which python3

which could say things like

python3 is hashed (/usr/bin/python3)

so cd into that dir and view its siblings as per

cd /usr/bin/

ls -la | grep python

for me on 18.10 its showing

lrwxrwxrwx  1 root root           26 Jul 23 08:39 dh_pypy -> ../share/dh-python/dh_pypy
-rwxr-xr-x  1 root root         1056 Jun  7  2018 dh_python2
lrwxrwxrwx  1 root root           29 Jul 23 08:39 dh_python3 -> ../share/dh-python/dh_python3
lrwxrwxrwx  1 root root            7 Sep 23 14:14 fail2ban-python -> python3
lrwxrwxrwx  1 root root           23 Oct  2 18:12 pdb2.7 -> ../lib/python2.7/pdb.py
lrwxrwxrwx  1 root root           23 Oct 22 07:32 pdb3.6 -> ../lib/python3.6/pdb.py
lrwxrwxrwx  1 root root           31 Oct 25 07:11 py3versions -> ../share/python3/py3versions.py
-rwxr-xr-x  1 root root          378 Aug 28 16:17 pybabel-python2
lrwxrwxrwx  1 root root           26 Jul 23 08:39 pybuild -> ../share/dh-python/pybuild
lrwxrwxrwx  1 root root            7 Jun  7  2018 python -> python2
lrwxrwxrwx  1 root root            9 Jun  7  2018 python2 -> python2.7
-rwxr-xr-x  1 root root      3690840 Oct  2 18:12 python2.7
lrwxrwxrwx  1 root root           33 Oct  2 18:12 python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root root           16 Jun  7  2018 python2-config -> python2.7-config
-rwxr-xr-x  1 root root          154 Sep 20 05:50 python2-pbr
lrwxrwxrwx  1 root root            9 Oct 25 07:11 python3 -> python3.6
-rwxr-xr-x  2 root root      4534680 Oct 22 07:32 python3.6
lrwxrwxrwx  1 root root           33 Oct 22 07:32 python3.6-config -> x86_64-linux-gnu-python3.6-config
-rwxr-xr-x  2 root root      4534680 Oct 22 07:32 python3.6m
lrwxrwxrwx  1 root root           34 Oct 22 07:32 python3.6m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx  1 root root           16 Oct 25 07:11 python3-config -> python3.6-config
lrwxrwxrwx  1 root root           10 Oct 25 07:11 python3m -> python3.6m
lrwxrwxrwx  1 root root           17 Oct 25 07:11 python3m-config -> python3.6m-config
lrwxrwxrwx  1 root root           14 Jun  7  2018 python-config -> python2-config
lrwxrwxrwx  1 root root           29 Jun  7  2018 pyversions -> ../share/python/pyversions.py
-rwxr-xr-x  1 root root         2971 Oct  2 18:12 x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root root           33 Jun  7  2018 x86_64-linux-gnu-python2-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx  1 root root           34 Oct 22 07:32 x86_64-linux-gnu-python3.6-config -> x86_64-linux-gnu-python3.6m-config
-rwxr-xr-x  1 root root         3283 Oct 22 07:32 x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx  1 root root           33 Oct 25 07:11 x86_64-linux-gnu-python3-config -> x86_64-linux-gnu-python3.6-config
lrwxrwxrwx  1 root root           34 Oct 25 07:11 x86_64-linux-gnu-python3m-config -> x86_64-linux-gnu-python3.6m-config
lrwxrwxrwx  1 root root           31 Jun  7  2018 x86_64-linux-gnu-python-config -> x86_64-linux-gnu-python2-config

for you you may see other python versions ...

Looks like 18.04 wants python3 to be 3.6.7 ... so issue

sudo update-alternatives --config python

and it should give you option to choose 3.6.7

Related Question