问题

问题

问题

任何命令都不会返回选项列表,例如不存在的plp

$ plp
Could not find command-not-found database. Run 'sudo apt update' to populate it.
plp: command not found

运行sudo apt update正常,问题依旧。
编辑:问题是没有列出哪个包可以提供该命令的建议,或者哪个命令接近该命令,不是命令是错误的。我期望输出如下:

Command 'plp' not found, did you mean:

  command 'pgp' from deb pgpgpg (0.13-9.1build1)
  command 'pp' from deb libpar-packer-perl (1.049-1)
  command 'pcp' from deb pcp (5.0.3-1)
  command 'clp' from deb coinor-clp (1.17.5+repack1-1)
  command 'php' from deb php7.4-cli (7.4.3-4ubuntu2.4)
  command 'tlp' from deb tlp (1.3.1-2)
  command 'plm' from deb plm (2.6+repack-3)
  command 'pyp' from deb pyp (2.12-2)
  command 'lp' from deb cups-client (2.3.1-9ubuntu1.1)
  command 'lp' from deb lprng (3.8.B-2.2)

Try: sudo apt install <deb name>

调查

询问 Ubuntu 告诉我运行apt-cache policy command-not-found{,-data}返回:

command-not-found:
  Installed: 20.04.4
  Candidate: 20.04.4
  Version table:
 *** 20.04.4 500
        500 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu focal-updates/main i386 Packages
        100 /var/lib/dpkg/status
     20.04.2 500
        500 http://us.archive.ubuntu.com/ubuntu focal/main amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu focal/main i386 Packages
N: Unable to locate package command-not-found-data

command-not-found-data不是已安装的命令。此外,在Debian 命令未找到错误跟踪器,该命令sudo update-command-not-found也无法被识别。

我认为数据库应该位于/var/lib/command-not-found,它是空的。

谢谢您的帮助,这个问题已经困扰我很长时间了!

答案1

所以最后,是因为我的机器没有正确安装。/usr/lib/python3/dist-packages/CommandNotFound/db/db.py所以import apt_pkg这个答案解决了,方法是:

cd /usr/lib/python3/dist-packages/
sudo ln -s apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so

相关内容