This post is for all Linux lovers and newbies. If you are getting an “Unable to locate package” error and want to resolve it. You have landed on the right page. When I started my Linux journey many years ago, I also got this error in Ubuntu.
There may be many reasons to encounter this error like the incorrect package name, Absolute path, package not available in repo and more. We will see all the related issues and solutions individually.
I am sure if you will follow this post step by step, You will be able to resolve the following errors. This post specifies Ubuntu but the solutions also apply to other Debian distros –
- Unable to locate package
- Unable to locate package ubuntu
- E unable to locate package Kali Linux
- Unable to locate package Debian
- E: unable to locate package update
- Unable to locate package pip
- Unable to locate package nodejs
- Unable to locate package python
All the above-mentioned errors may occur due to different scenarios. I will replicate these errors and then give you a solution for easy understanding.
Below mentioned are the Possible Causes for most of the errors –
- The package name is incorrect or case sensitive problem
- Providing a file name instead of the package name
- Not providing a full path to your downloaded .deb package
- Forgot to update the repository, after a fresh Ubuntu installation
- The package is not available for your Ubuntu version in the official repository
- Your Ubuntu or Debian distro reached the end of life
- The apt command syntax is not correct
- /etc/apt/sources.list is missing or corrupted
Let’s deep dive and find solution to these possible cause –
Solution 1 – How to Fix “Unable to locate package in Ubuntu” error due to incorrect package name
It may sound silly, but yes, I still do this mistake very frequently. Sometimes I type the wrong package name while installing packages in my Ubuntu system.
I have no doubt about your intelligence, but typing errors may happen with anyone. Also If you are a newbie, keep in mind that Linux is case-sensitive.
These are the very common mistakes that happen during package installation –
- The package name is not correct or not known
- Lowercase or upper case issue in the package name
- Not providing specific or complete package name with version
Let me show you this with an example –
I want to install Java (version 11) in my Ubuntu 20.04 and I am not aware of the package name. If I will assume and try to install it with the name “java”, it won’t work.
I am getting “unable to locate package java“. Because it doesn’t exist with this name.
$ sudo apt install java
The name of Java package starts with “openjdk” in real.
How to find a package in Ubuntu repository, if exact package name not known
To find out the correct name of your package, you can follow these simple steps. It will make sure, there is no issue related to package name, lower or uppercase and even versions.
Step1.1 – Visit the Ubuntu package archive site and select your Ubuntu distro version
Visit https://packages.ubuntu.com/ and search for your package.
I am using Ubuntu 20.04. I will select focal (20.04LTS) from the list. You need to select your distro. You can check your Ubuntu version to get these details.
Step1.2 – Choose your package category
On this page, You will get a lot of sections like Administration utilities, Database, Development etc. to make your search easy.
Choose your section to deep down one more level. For example, I will select Java from the section –
Step1.2 – Search for your package from the subsection list
Search for your required package name. For example, I will look out for Java development kit version 11.
So I gave “development kit” in the search box and reached for the package openjdk-11-jdk.
You may need to do some hit-and-trial or manual search to reach your package when you are really clueless about your package name.
Step1.3 – Install your required package using the apt command
Now I know the correct name and package version i.e. openjdk-11-jdk. I will be able to install it without any issues.
$ sudo apt install openjdk-11-jdk
Solution 2 – Provide an absolute package (.deb) path, for offline package installation
In case your package is not available in the official Ubuntu repository and you have downloaded (.deb) package from the third-party site.
You are getting “unable to locate package” while installing it offline. It means you are not giving an absolute path to your .deb package file.
Let me explain to you with an example –
Google Chrome browser is not part of the Ubuntu official repository. So I downloaded the .deb package of chrome and tried to install it.
Google Chrome “.deb” file exists in my Downloads directory. and if you notice in the image, I am in the same directory. But still, I am getting an “unable to locate package google-chrome-stable_current_amd64.deb” error.
$ sudo apt-get install google-chrome-stable_current_amd64.deb
Now I will just provide an absolute path to the .deb package file and it will work like a charm.
$ sudo apt-get install ./google-chrome-stable_current_amd64.deb
Solution 3 – Update and build local repository cache
You may encounter this scenario if you have installed Ubuntu fresh and trying to update or install packages. Additionally, You are new to the Linux world.
Let me highlight, You must run “apt update” first to build a local cache repository. Otherwise, an empty cache will not return anything.
Actually, the package manager fetches the metadata of available packages over the network. Then it builds a local cache in the system, to provide a fast result to your package query.
The local cache repository may get stale anytime. So please make a thumb rule. Always update the package repository first and then only install the package. It is applicable to all Debian distros.
$ sudo apt update
Then install the required package.
$ sudo apt install "your-package-name"
Solution 4 – “Unable to locate package” in Ubuntu official repository
There are cases when you try to install the Ubuntu package. It may or may not exist in the repository.
So first, we should search manually and confirm the package availability, then we can go with external or third-party repositories.
How to search packages in the Ubuntu repository using CLI and GUI
There are two ways to verify it –
- Find a package in the Ubuntu repository using GUI
- To find a package using the apt-cache command in terminal
Step 4.1 – Search for a package in the Ubuntu repository {GUI}
- Open terminal <Ctrl +Alt + T> in Ubuntu and find out your distro code name using “lsb_release” command.
For example, I am using Ubuntu 20.04, with the code name “Focal“.
dev@ubuntu:~/Desktop$ lsb_release -c Codename: focal
- Visit Ubuntu repository page > Scroll down to the search section
- Fill “package name” in the keyword and select “Distribution“. In my case, it will be focal.
- Hit the “Search” button.
For example, I will look for the TeamViewer package. It’s used to connect a system remotely over the Internet or intranet.
So I was unable to find it in the Ubuntu repository –
Step 4.2 (Optional) – Search for a package in Ubuntu repository {CLI}
If you don’t to leave your terminal and want to search packages in the Ubuntu repository using CLI. Follow these steps –
Run this command in terminal –
$ sudo apt-cache search "your-package-name" or $ sudo apt-cache search . | grep -i "package-name"
For example –
$ sudo apt-cache search teamviewer or $ sudo apt-cache searcch . | grep -i teamviewer
If you are not getting any results from this search query, the package doesn’t exist in the Ubuntu repository. You need to download and install it using a third-party site or repository (PPA).
You can check out this article, to see the different ways to install packages in Ubuntu and TeamViewer installation.
Solution 5 – Your Ubuntu or Debian distro reached the end of life
You can encounter an “unable to locate package error” in case your Ubuntu or Debian distro is legacy or very old.
Ubuntu or any Linux vendor, don’t provide support or the latest package release for end-of-life distros.
For example, Ubuntu 14.04 is already at the end of life and Ubuntu 16.04 will obsolete in April 2021.
So you must plan for an upgrade, in case you are still using these old versions and want to avoid package-related issues.
Solution 6 – /etc/apt/sources.list is missing or corrupted
The “sources.list” file contains all your Ubuntu and third-party repository URLs. So whenever you run the apt command to install any package. It checks within this file and gives results.
You may encounter “E: unable to locate package“, if /etc/apt/sources.list file is missing or corrupt.
One of the reasons for corruption is incorrect editing of sources.list file.
I have deleted my sources.list file just to replicate the issue and I started getting the “unable to locate package” error.
For example, if I try to install any package like python, I am getting an error as shown in the output –
dev@ubuntu:~$ sudo apt install python Reading package lists… Done Building dependency tree Reading state information… Done E: Unable to locate package python
and the same for nodejs package installation. So it confirms, that issue is with sources.list file because I am unable to install any package.
dev@ubuntu:~$ sudo apt install nodejs Reading package lists… Done Building dependency tree Reading state information… Done E: Unable to locate package nodejs
How to Fix /etc/apt/sources.list is missing or corrupted
Follow these easy instructions to rebuild sources.list file again.
Step 6.1 – Delete existing corrupt /etc/apt/sources.list file, if it exists.
If your sources.list file is corrupt, then you need to delete it first. If it’s already missing, then you can skip this step.
$ sudo rm -rf /etc/apt/sources.list
Step 6.2 – Regenerate sources.list file
Run the following command –
$ sudo software-properties-gtk
You will get the Software and Updates window. Select all the checkboxes as shown in the image. Also, select the “main server” in Download from the dropdown.
Click Close.
You will get a warning to reload or refresh the repository cache. Select <reload> to generate sources.list file and apt-cache. it’s like running the apt-get update command from the terminal.
It will take a few seconds to refresh the software cache.
You can later add third-party repository as needed.
Now you can easily install your nodejs or python package. You will not get the “unable to locate package nodejs” error anymore.
Video tutorial
Watch this informative video tutorial for 6 solutions on “How to fix the “unable to locate package” error in Ubuntu. This is really helpful if you don’t like reading or have any doubts about the steps.
Frequently Asked Questions
Why am I getting unable to locate package fglrx-updates?
If you are searching for fglrx-updates, then you may have Ubuntu 14.04 installed in your system. It’s already obsolete. So I would suggest you upgrade your system to the latest Ubuntu 22.04 system and run the following command to install the fglrx
package in your system.
$ sudo apt update
$ sudo apt install fglrx-pxpress
Why am I getting Unable to locate package uboot-tools?
If you are trying to install Uboot tools (companion tools for Das U-Boot bootloader) in your Linux and getting the error unable to locate package uboot-tools. You are giving the package name wrong. The correct package is u-boot-tools, Follow these commands to install Uboot tools in your system.
$ sudo apt update
$ sudo apt install u-boot-tools
Unable to locate package Linux-backports-modules-jaunty, Why?
Jaunty Linux is the codename of Ubuntu 9.04, which is an obsolete Ubuntu Linux version. It’s not supported anymore. So I would recommend you upgrade your Linux system if you are still using jaunty in your office or home.
Conclusion
If you are getting this common “unable to locate package” error in Ubuntu or other Distros like Linux Mint. I hope, resolving this error would be a cakewalk for you after reading this post.
If you find any scenario while using Linux, which is not covered in this post. Let me know through your comments. I will try to add that also in this post.
If you find it useful, Please share it with your friends on social media.
Happy learning…