我刚刚发现我同时安装了gcc-10和gcc-11 (并安装了apt purge gcc-10 && apt autoremove)。
我想知道在多个版本中安装的其他软件包可能有哪些?
PS。看来gcc-12也存在,但apt install gcc-12 && apt purge gcc-11由于unmet dependencies而失败)
发布于 2022-10-25 14:52:19
下面是我最后使用的内容:
import subprocess as sp
versioned = {}
with sp.Popen(["apt","list","--installed"], encoding="ascii",
stdout=sp.PIPE, stderr=sp.STDOUT) as pipe:
for pack in pipe.stdout:
if "/" not in pack:
print(pack)
continue
name = pack.split("/",1)[0]
name_ver = name.rsplit("-",1)
if len(name_ver) == 2 and name_ver[1].isdigit():
versioned.setdefault(name_ver[0],set()).add(name_ver[1])
print(f"found {len(versioned):,d} versioned packages")
versioned = {n:v for n,v in versioned.items() if len(v) > 1}
print(f"found {len(versioned):,d} packages with multiple versions:\n{versioned}")哪种指纹
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Listing...
found 240 versioned packages
found 3 packages with multiple versions:
{'cpp': {'12', '11'}, 'g++': {'12', '11'}, 'gcc': {'12', '11'}}https://askubuntu.com/questions/1437148
复制相似问题