解决无法运行Terminator出现以下问题: File "/usr/bin/terminator"...SyntaxError: invalid syntax

时间:2022-11-07 20:06:43

在安装或者启动Terminator时可能出现这个问题:

lin@Dev:~$ terminator
File "/usr/bin/terminator", line 123
except (KeyError,ValueError), ex:
^
SyntaxError: invalid syntax

错误原因:语法错误.这是因为Terminator的安装或者运行需要python2的环境,但是却用python3的环境去运行Terminator了.

我们查看Terminator的启动脚本文件,在'/usr/bin'下.

vi /usr/bin/terminator
#!/usr/bin/python
# Terminator - multiple gnome terminals in one window
# Copyright (C) 2006-2010 cmsj@tenshu.net
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 only.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
# USA """Terminator by Chris Jones <cmsj@tenshu.net>""" import sys
import os
import psutil
....
....

第一行标示使用的是系统默认的python脚本.

系统安装的python的版本有两个分别是python2.7和python3.6,当python链接到python2.7时,程序运行正常,链接到python3.6时出现以上的语法错误。

解决方法

1. 将系统默认的python版本链接到2(不建议)

2.  修改terminator的启动脚本(/usr/bin/terminator)如下:

#! /usr/bin/python2

保存退出重新运营terminator,成功.