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


    在安装或者启动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,成功.

  • 相关阅读:
    如何让django方法自动地定期执行
    Python的PIL库实现验证码图片
    解决Python2.7的UnicodeEncodeError: 'ascii' codec can’t encode异常错误
    js分页页码算法
    Django站点管理--ModelAdmin
    Django时间查询
    django orm总结
    django Q和F查询
    ubuntu安装redis
    买入股票必须遵循的原则
  • 原文地址:https://www.cnblogs.com/lishanlei/p/10707869.html
Copyright © 2020-2023  润新知