运行softwaresources会导致Python错误(LMDE 3)

2024-04-20 04:05:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要运行软件源GUI(不,我的作业不能通过aptaptitude完成)。因为如果从启动程序导航,窗口永远不会加载,所以我决定看看如果从命令行运行它会发生什么:

jason@jason-mint:~$ software-sources 
  File "/usr/lib/linuxmint/mintSources/mintSources.py", line 48
    def async(func):
            ^
SyntaxError: invalid syntax

文件mintSources.py中的函数如下所示:

# Used as a decorator to run things in the background
def async(func):
    def wrapper(*args, **kwargs):
        thread = threading.Thread(target=func, args=args, kwargs=kwargs)
        thread.daemon = True
        thread.start()
        return thread
    return wrapper

在最上面,shebang说:#!/usr/bin/python3。因为我的默认Python是Python2.7,所以我将shebang更改为#!/usr/bin/python,以查看发生了什么,但这次出现了一个新错误:

jason@jason-mint:/etc/apt$ software-sources 
Traceback (most recent call last):
  File "/usr/lib/linuxmint/mintSources/mintSources.py", line 6, in <module>
    import configparser
ImportError: No module named configparser

这意味着它在import configparser中失败,这显然表明python2.7(我的默认值)将不起作用。为了澄清,我提供了Python2Python3:

jason@jason-mint:~$ python --version
Python 2.7.16
jason@jason-mint:~$ python2
Python 2.7.16 (default, Apr  6 2019, 01:42:57) 
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
jason@jason-mint:~$ python3
Python 3.7.3rc1 (default, Mar 13 2019, 11:01:15) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> quit()
jason@jason-mint:~$ python
Python 2.7.16 (default, Apr  6 2019, 01:42:57) 
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.

一些系统信息如果有帮助:

jason@jason-mint:~$ cat /etc/debian_version 
buster/sid
jason@jason-mint:~$ uname -r
4.19.0-4-amd64

Tags: pydefaultonusrdeftypeargsthread