Ubuntu Linux Unable to Install Packages
There are many different reasons that packages may not install. Perhaps you are out of space, inodes, have permission problems, have network connectivity problems, and so on. An additional challenge that has recently come up is the apt package manager reporting that a package isn’t even available when you know it should be.
One great example of this is python-pip. So let’s say that you’re trying to install it so you issue the standard command to install…
$ sudo apt install python-pip
Simple enough right? Maybe not… you might end up with the message below.
Reading package lists… Done
Building dependency tree Reading state information… Done
E: Unable to locate package python-pip
Great… so it can’t find it and even using apt search won’t turn up results. This is because several packages that are NOT truly open-source have been moved out of the main distribution. From what I have been told this is the case in other distributions as well (but the fix is likely to be slightly different).
So how do we fix this annoying problem? Update and append universe to the end of each of our repository lines in /etc/apt/sources.list
Now look at your repositories, for the latest 18.04 release they are shown similarly as indicated below.
deb http://archive.ubuntu.com/ubuntu bionic main
deb http://archive.ubuntu.com/ubuntu bionic-security main
deb http://archive.ubuntu.com/ubuntu bionic-updates main
Update those lines to add universe to the end of the lines as suggested above and now shown below.
deb http://archive.ubuntu.com/ubuntu bionic main universe
deb http://archive.ubuntu.com/ubuntu bionic-security main universe
deb http://archive.ubuntu.com/ubuntu bionic-updates main universe
Now you should be able to issue a new apt update command and install the missing packages.
Please be aware that again, these packages were split out due to licensing concerns so if you are using these for anything more than personal use you should make certain that you are not violating licensing agreements before making the changes and installing as I’ve shown above.
$ sudo apt update
$ sudo apt install <package name>
And you now should be good to go!