Gnome terminal will not start











up vote
18
down vote

favorite
5












I just tried to install python 3.6 on my Ubuntu 16.04 system, and now I cant run the terminal from the launcher or from Ctrl+Alt+T. I tried to run gnome-terminal from XTerm and got the following message:



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'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
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'


How can I fix this error?



It should also be noted that:




  • My gnome-terminal file is now a python script.

  • The gnome-terminal.real file will open the terminal as expected.


  • python3.5 gnome-terminal will open the terminal as expected.










share|improve this question




























    up vote
    18
    down vote

    favorite
    5












    I just tried to install python 3.6 on my Ubuntu 16.04 system, and now I cant run the terminal from the launcher or from Ctrl+Alt+T. I tried to run gnome-terminal from XTerm and got the following message:



    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'
    Error in sys.excepthook:
    Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
    File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
    File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
    File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
    File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
    import apt
    File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
    ModuleNotFoundError: No module named 'apt_pkg'

    Original exception was:
    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'


    How can I fix this error?



    It should also be noted that:




    • My gnome-terminal file is now a python script.

    • The gnome-terminal.real file will open the terminal as expected.


    • python3.5 gnome-terminal will open the terminal as expected.










    share|improve this question


























      up vote
      18
      down vote

      favorite
      5









      up vote
      18
      down vote

      favorite
      5






      5





      I just tried to install python 3.6 on my Ubuntu 16.04 system, and now I cant run the terminal from the launcher or from Ctrl+Alt+T. I tried to run gnome-terminal from XTerm and got the following message:



      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'
      Error in sys.excepthook:
      Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
      from apport.fileutils import likely_packaged, get_recent_crashes
      File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
      from apport.report import Report
      File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
      import apport.fileutils
      File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
      from apport.packaging_impl import impl as packaging
      File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
      import apt
      File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
      import apt_pkg
      ModuleNotFoundError: No module named 'apt_pkg'

      Original exception was:
      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'


      How can I fix this error?



      It should also be noted that:




      • My gnome-terminal file is now a python script.

      • The gnome-terminal.real file will open the terminal as expected.


      • python3.5 gnome-terminal will open the terminal as expected.










      share|improve this question















      I just tried to install python 3.6 on my Ubuntu 16.04 system, and now I cant run the terminal from the launcher or from Ctrl+Alt+T. I tried to run gnome-terminal from XTerm and got the following message:



      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'
      Error in sys.excepthook:
      Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
      from apport.fileutils import likely_packaged, get_recent_crashes
      File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
      from apport.report import Report
      File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
      import apport.fileutils
      File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
      from apport.packaging_impl import impl as packaging
      File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
      import apt
      File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
      import apt_pkg
      ModuleNotFoundError: No module named 'apt_pkg'

      Original exception was:
      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'


      How can I fix this error?



      It should also be noted that:




      • My gnome-terminal file is now a python script.

      • The gnome-terminal.real file will open the terminal as expected.


      • python3.5 gnome-terminal will open the terminal as expected.







      16.04 gnome python gnome-terminal






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 5 '17 at 19:50

























      asked Feb 5 '17 at 19:45









      bengdahl

      9315




      9315






















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          22
          down vote



          accepted










          Probably the symlink /usr/bin/python3 points to python3.6, which it should not. Fix it by running these commands:



          sudo rm /usr/bin/python3
          sudo ln -s python3.5 /usr/bin/python3





          share|improve this answer

















          • 4




            To add to this: this is caused by a bug in the python3-apt package; there's a Launchpad bug open about it here.
            – Josh
            Feb 6 '17 at 14:31










          • The symlink should be created on which path ? Isn't pyenv a better alternative until the terminal bug is fixed ?
            – josircg
            Mar 17 at 15:44










          • @josircg: Not sure I understand your path question. Both the symlink and the executable reside in /usr/bin. There may well be better alternatives. If you know of any, please write an own answer.
            – Gunnar Hjalmarsson
            Mar 17 at 19:42










          • About the path: it think it's wise to add a cd /usr/bin before the ln, right?
            – josircg
            Mar 17 at 20:04










          • About the solution: if you try to enable again python 3.6, you wil have to remove/recreate the symlink again. This should be noted too on the solution.
            – josircg
            Mar 17 at 20:06


















          up vote
          6
          down vote













          You don't have to point Python3 to python3.5 , just running the commands:



          cd /usr/lib/python3/dist-packages/gi/
          sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-36m-x86_64-linux-gnu.so
          sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-36m-x86_64-linux-gnu.so





          share|improve this answer























          • What does this do exactly? Is it safe?
            – wjandrea
            Aug 1 at 19:52






          • 1




            This should be the answer. It is safe @wjandrea , I use it without any problem with Python 3.7 under Ubuntu 18
            – zixia
            Sep 7 at 6:27












          • Can you paste these into xterm?
            – Tahlor
            Sep 12 at 21:24











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f880188%2fgnome-terminal-will-not-start%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          22
          down vote



          accepted










          Probably the symlink /usr/bin/python3 points to python3.6, which it should not. Fix it by running these commands:



          sudo rm /usr/bin/python3
          sudo ln -s python3.5 /usr/bin/python3





          share|improve this answer

















          • 4




            To add to this: this is caused by a bug in the python3-apt package; there's a Launchpad bug open about it here.
            – Josh
            Feb 6 '17 at 14:31










          • The symlink should be created on which path ? Isn't pyenv a better alternative until the terminal bug is fixed ?
            – josircg
            Mar 17 at 15:44










          • @josircg: Not sure I understand your path question. Both the symlink and the executable reside in /usr/bin. There may well be better alternatives. If you know of any, please write an own answer.
            – Gunnar Hjalmarsson
            Mar 17 at 19:42










          • About the path: it think it's wise to add a cd /usr/bin before the ln, right?
            – josircg
            Mar 17 at 20:04










          • About the solution: if you try to enable again python 3.6, you wil have to remove/recreate the symlink again. This should be noted too on the solution.
            – josircg
            Mar 17 at 20:06















          up vote
          22
          down vote



          accepted










          Probably the symlink /usr/bin/python3 points to python3.6, which it should not. Fix it by running these commands:



          sudo rm /usr/bin/python3
          sudo ln -s python3.5 /usr/bin/python3





          share|improve this answer

















          • 4




            To add to this: this is caused by a bug in the python3-apt package; there's a Launchpad bug open about it here.
            – Josh
            Feb 6 '17 at 14:31










          • The symlink should be created on which path ? Isn't pyenv a better alternative until the terminal bug is fixed ?
            – josircg
            Mar 17 at 15:44










          • @josircg: Not sure I understand your path question. Both the symlink and the executable reside in /usr/bin. There may well be better alternatives. If you know of any, please write an own answer.
            – Gunnar Hjalmarsson
            Mar 17 at 19:42










          • About the path: it think it's wise to add a cd /usr/bin before the ln, right?
            – josircg
            Mar 17 at 20:04










          • About the solution: if you try to enable again python 3.6, you wil have to remove/recreate the symlink again. This should be noted too on the solution.
            – josircg
            Mar 17 at 20:06













          up vote
          22
          down vote



          accepted







          up vote
          22
          down vote



          accepted






          Probably the symlink /usr/bin/python3 points to python3.6, which it should not. Fix it by running these commands:



          sudo rm /usr/bin/python3
          sudo ln -s python3.5 /usr/bin/python3





          share|improve this answer












          Probably the symlink /usr/bin/python3 points to python3.6, which it should not. Fix it by running these commands:



          sudo rm /usr/bin/python3
          sudo ln -s python3.5 /usr/bin/python3






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 5 '17 at 19:54









          Gunnar Hjalmarsson

          18.9k23261




          18.9k23261








          • 4




            To add to this: this is caused by a bug in the python3-apt package; there's a Launchpad bug open about it here.
            – Josh
            Feb 6 '17 at 14:31










          • The symlink should be created on which path ? Isn't pyenv a better alternative until the terminal bug is fixed ?
            – josircg
            Mar 17 at 15:44










          • @josircg: Not sure I understand your path question. Both the symlink and the executable reside in /usr/bin. There may well be better alternatives. If you know of any, please write an own answer.
            – Gunnar Hjalmarsson
            Mar 17 at 19:42










          • About the path: it think it's wise to add a cd /usr/bin before the ln, right?
            – josircg
            Mar 17 at 20:04










          • About the solution: if you try to enable again python 3.6, you wil have to remove/recreate the symlink again. This should be noted too on the solution.
            – josircg
            Mar 17 at 20:06














          • 4




            To add to this: this is caused by a bug in the python3-apt package; there's a Launchpad bug open about it here.
            – Josh
            Feb 6 '17 at 14:31










          • The symlink should be created on which path ? Isn't pyenv a better alternative until the terminal bug is fixed ?
            – josircg
            Mar 17 at 15:44










          • @josircg: Not sure I understand your path question. Both the symlink and the executable reside in /usr/bin. There may well be better alternatives. If you know of any, please write an own answer.
            – Gunnar Hjalmarsson
            Mar 17 at 19:42










          • About the path: it think it's wise to add a cd /usr/bin before the ln, right?
            – josircg
            Mar 17 at 20:04










          • About the solution: if you try to enable again python 3.6, you wil have to remove/recreate the symlink again. This should be noted too on the solution.
            – josircg
            Mar 17 at 20:06








          4




          4




          To add to this: this is caused by a bug in the python3-apt package; there's a Launchpad bug open about it here.
          – Josh
          Feb 6 '17 at 14:31




          To add to this: this is caused by a bug in the python3-apt package; there's a Launchpad bug open about it here.
          – Josh
          Feb 6 '17 at 14:31












          The symlink should be created on which path ? Isn't pyenv a better alternative until the terminal bug is fixed ?
          – josircg
          Mar 17 at 15:44




          The symlink should be created on which path ? Isn't pyenv a better alternative until the terminal bug is fixed ?
          – josircg
          Mar 17 at 15:44












          @josircg: Not sure I understand your path question. Both the symlink and the executable reside in /usr/bin. There may well be better alternatives. If you know of any, please write an own answer.
          – Gunnar Hjalmarsson
          Mar 17 at 19:42




          @josircg: Not sure I understand your path question. Both the symlink and the executable reside in /usr/bin. There may well be better alternatives. If you know of any, please write an own answer.
          – Gunnar Hjalmarsson
          Mar 17 at 19:42












          About the path: it think it's wise to add a cd /usr/bin before the ln, right?
          – josircg
          Mar 17 at 20:04




          About the path: it think it's wise to add a cd /usr/bin before the ln, right?
          – josircg
          Mar 17 at 20:04












          About the solution: if you try to enable again python 3.6, you wil have to remove/recreate the symlink again. This should be noted too on the solution.
          – josircg
          Mar 17 at 20:06




          About the solution: if you try to enable again python 3.6, you wil have to remove/recreate the symlink again. This should be noted too on the solution.
          – josircg
          Mar 17 at 20:06












          up vote
          6
          down vote













          You don't have to point Python3 to python3.5 , just running the commands:



          cd /usr/lib/python3/dist-packages/gi/
          sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-36m-x86_64-linux-gnu.so
          sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-36m-x86_64-linux-gnu.so





          share|improve this answer























          • What does this do exactly? Is it safe?
            – wjandrea
            Aug 1 at 19:52






          • 1




            This should be the answer. It is safe @wjandrea , I use it without any problem with Python 3.7 under Ubuntu 18
            – zixia
            Sep 7 at 6:27












          • Can you paste these into xterm?
            – Tahlor
            Sep 12 at 21:24















          up vote
          6
          down vote













          You don't have to point Python3 to python3.5 , just running the commands:



          cd /usr/lib/python3/dist-packages/gi/
          sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-36m-x86_64-linux-gnu.so
          sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-36m-x86_64-linux-gnu.so





          share|improve this answer























          • What does this do exactly? Is it safe?
            – wjandrea
            Aug 1 at 19:52






          • 1




            This should be the answer. It is safe @wjandrea , I use it without any problem with Python 3.7 under Ubuntu 18
            – zixia
            Sep 7 at 6:27












          • Can you paste these into xterm?
            – Tahlor
            Sep 12 at 21:24













          up vote
          6
          down vote










          up vote
          6
          down vote









          You don't have to point Python3 to python3.5 , just running the commands:



          cd /usr/lib/python3/dist-packages/gi/
          sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-36m-x86_64-linux-gnu.so
          sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-36m-x86_64-linux-gnu.so





          share|improve this answer














          You don't have to point Python3 to python3.5 , just running the commands:



          cd /usr/lib/python3/dist-packages/gi/
          sudo cp _gi.cpython-35m-x86_64-linux-gnu.so _gi.cpython-36m-x86_64-linux-gnu.so
          sudo cp _gi_cairo.cpython-35m-x86_64-linux-gnu.so _gi_cairo.cpython-36m-x86_64-linux-gnu.so






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jul 31 at 22:24









          wjandrea

          8,04342258




          8,04342258










          answered Jan 26 at 8:48









          Inno Jia

          6111




          6111












          • What does this do exactly? Is it safe?
            – wjandrea
            Aug 1 at 19:52






          • 1




            This should be the answer. It is safe @wjandrea , I use it without any problem with Python 3.7 under Ubuntu 18
            – zixia
            Sep 7 at 6:27












          • Can you paste these into xterm?
            – Tahlor
            Sep 12 at 21:24


















          • What does this do exactly? Is it safe?
            – wjandrea
            Aug 1 at 19:52






          • 1




            This should be the answer. It is safe @wjandrea , I use it without any problem with Python 3.7 under Ubuntu 18
            – zixia
            Sep 7 at 6:27












          • Can you paste these into xterm?
            – Tahlor
            Sep 12 at 21:24
















          What does this do exactly? Is it safe?
          – wjandrea
          Aug 1 at 19:52




          What does this do exactly? Is it safe?
          – wjandrea
          Aug 1 at 19:52




          1




          1




          This should be the answer. It is safe @wjandrea , I use it without any problem with Python 3.7 under Ubuntu 18
          – zixia
          Sep 7 at 6:27






          This should be the answer. It is safe @wjandrea , I use it without any problem with Python 3.7 under Ubuntu 18
          – zixia
          Sep 7 at 6:27














          Can you paste these into xterm?
          – Tahlor
          Sep 12 at 21:24




          Can you paste these into xterm?
          – Tahlor
          Sep 12 at 21:24


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f880188%2fgnome-terminal-will-not-start%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents