1

I'm unable to remove the package python3-pip in 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

Is there a way to force apt to completely remove the package?

Edit 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
$
  • What does apt list --installed | grep python3-pip return? – Terrance Mar 1 '17 at 14:28
  • @cl-netbox Yep, that works too. My comment here is based on the command that is being run. The one part that is missing from OPs command is the --installed. The command of list lists all packages regardless of being installed or not. – Terrance Mar 1 '17 at 14:47
  • python3-pip is not installed on the computer. – Terrance Mar 1 '17 at 14:49
5

First check whether the package is installed :

$ 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  

In case it is (in this example it's not) execute :

sudo apt purge python3-pip  

In case you mistakenly chose the wrong one :

dpkg --get-selections | grep python3  

You get a list of installed python3 packages.

Clarification and general information : Your Edit 1 output shows that the package is not installed and hence it cannot be removed. The apt list command shows available packages, it does NOT show installed packages, unless you add --installed to the apt list command as mentioned in the comment from @Terrance. And, be very careful which packages you remove as pointed out by @ByteCommander ... sudo apt purge completely removes packages and configuration files !

  • If you look at edit 1, you see that the package doesn't seem to be installed, but still, it appears in the apt list output. – boardrider Mar 1 '17 at 14:49
  • 2
    @boardrider The apt list command shows available packages ... NOT installed packages. :) – cl-netbox Mar 1 '17 at 14:55
  • 2
    Just a side note, make sure you do not accidentally remove the complete python3 if you want your system to remain usable. Only remove module packages for Python 3 which you manually installed yourself. – Byte Commander Mar 1 '17 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.