我怎样才能彻底删除一个包?

我怎样才能彻底删除一个包?

我无法python3-pip在 Ubuntu 16.04 中删除该软件包:

$ apt list |& grep 'python3-pip/'
python3-pip/xenial-updates,xenial-updates 8.1.1-2ubuntu0.4 all
$ sudo apt-get remove python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'python3-pip' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
openstack@prclnx04:~/python/pybind11$ apt list |& grep 'python3-pip/'
python3-pip/xenial-updates,xenial-updates 8.1.1-2ubuntu0.4 all
$ sudo dpkg --remove --force-remove-reinstreq python3-pip
dpkg: warning: ignoring request to remove python3-pip which isn't installed
$ sudo dpkg --remove --force-remove-reinstreq python3-pip
dpkg: warning: ignoring request to remove python3-pip which isn't installed
$ sudo apt-get update
Ign:1 http://archive.ubuntu.com/ubuntu trusty InRelease
Hit:2 http://ppa.launchpad.net/diesch/testing/ubuntu xenial InRelease
Hit:3 http://archive.ubuntu.com/ubuntu trusty Release
Hit:4 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial InRelease
Hit:6 http://archive.linux.duke.edu/ubuntu xenial InRelease
Hit:7 http://archive.linux.duke.edu/ubuntu xenial-updates InRelease
Hit:8 http://archive.linux.duke.edu/ubuntu xenial-backports InRelease
Hit:9 http://archive.linux.duke.edu/ubuntu xenial-security InRelease
Reading package lists... Done
$ apt list |& grep 'python3-pip/'           
python3-pip/xenial-updates,xenial-updates 8.1.1-2ubuntu0.4 all
$ sudo apt-get clean && sudo apt-get autoclean && sudo apt-get autoremove --purge python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package 'python3-pip' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ apt list |& grep 'python3-pip/'           
python3-pip/xenial-updates,xenial-updates 8.1.1-2ubuntu0.4 all

有没有办法强制apt彻底删除该包?

编辑1:

$ apt policy python3-pip
python3-pip:
  Installed: (none)
  Candidate: 8.1.1-2ubuntu0.4
  Version table:
     8.1.1-2ubuntu0.4 500
        500 http://archive.linux.duke.edu/ubuntu xenial-updates/universe amd64 Packages
        500 http://archive.linux.duke.edu/ubuntu xenial-updates/universe i386 Packages
     8.1.1-2 500
        500 http://archive.linux.duke.edu/ubuntu xenial/universe amd64 Packages
        500 http://archive.linux.duke.edu/ubuntu xenial/universe i386 Packages
     1.5.4-1 500
        500 http://archive.ubuntu.com/ubuntu trusty/universe amd64 Packages
        500 http://archive.ubuntu.com/ubuntu trusty/universe i386 Packages
$ apt list |& grep 'python3-pip/'
python3-pip/xenial-updates,xenial-updates 8.1.1-2ubuntu0.4 all
$

$ apt list --installed | grep python3-pip

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

$ dpkg --get-selections | grep python3-pip
$ apt list |& grep 'python3-pip/'
python3-pip/xenial-updates,xenial-updates 8.1.1-2ubuntu0.4 all
$

答案1

首先检查包是否已安装:

$ apt policy python3-pip
python3-pip:
  Installed: (none)
  Candidate: 8.1.2-2ubuntu0.1
  Version table:
     8.1.2-2ubuntu0.1 500
        500 http://archive.ubuntu.com/ubuntu yakkety-updates/universe amd64 Packages
        500 http://archive.ubuntu.com/ubuntu yakkety-updates/universe i386 Packages
     8.1.2-2 500
        500 http://archive.ubuntu.com/ubuntu yakkety/universe amd64 Packages
        500 http://archive.ubuntu.com/ubuntu yakkety/universe i386 Packages  

如果是(在这个例子中不是)则执行:

sudo apt purge python3-pip  

如果您错误地选择了错误的一个:

dpkg --get-selections | grep python3  

您将获得已安装软件包的列表python3

澄清和一般信息:您的编辑 1 输出显示该软件包未安装,因此无法删除。该apt list命令显示可用的软件包,它不会显示已安装的软件包,除非您按照 @Terrance 的评论中提到的方式添加--installedapt list命令中。并且,正如 @ByteCommander 所指出的那样,在删除软件包时要非常小心...sudo apt purge完全删除软件包和配置文件!

答案2

当软件包中含有标志‘ic’时dpkg -l,它们就不能被 apt 删除,而必须使用dpkg -P <package>

相关内容