7

When I run terminator in terminal, it doesn't work. The error is this:

$ terminator

  File "/usr/bin/terminator", line 119
    except (KeyError,ValueError), ex:

                                ^
SyntaxError: invalid syntax

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:

  File "/usr/bin/terminator", line 119

    except (KeyError,ValueError), ex:
                                ^

SyntaxError: invalid syntax

How can I fix it? I use Ubuntu 16.04.

4
  • What is the output of which python? Also, what is the first line of /usr/bin/terminator? Is it something like #!/usr/bin/python3? or is it #!/usr/bin/python?
    – Kulfy
    Feb 6, 2019 at 18:00
  • It is #!/usr/bin/python
    – Alex Seo
    Feb 8, 2019 at 9:18
  • Do you have python2 installed? Run sudo apt install python or what is the output of which python?
    – Kulfy
    Feb 8, 2019 at 12:38
  • This solution worked for me. Thank you.
    – l1nk
    Dec 19, 2019 at 10:47

3 Answers 3

12

I fixed it by editing /usr/bin/terminator and changing the python version. First, open the file with:

sudo nano /usr/bin/terminator

Then, change the first line from this:

#!/usr/bin/python

To this:

#!/usr/bin/python2

Finally, save the file and you're ready to go!

1
  • 1
    This solution temporally fixed the issue but I guess the update of terminator will break it again.
    – iMitwe
    Aug 20, 2019 at 22:09
3

Terminator require python2 libraries but from your output it seems it is using python3 to run. Also, according to release notes of Ubuntu 18.04,

Python 2 is no longer installed by default. Python 3 has been updated to 3.6. This is the last LTS release to include Python 2 in main.

To install Python2 in 18.04, run:

sudo apt install python-minimal
1

Consider to reinstall packages with apt_pkg with

sudo apt-get install --reinstall python-apt python3-apt

and to be completely sure reinstall Terminator with

sudo apt-get install --reinstall terminator
1
  • I tried your solution but it didn't work. It had same problem
    – Alex Seo
    Feb 6, 2019 at 14:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .