HomeLinux“E: Unable to locate package” Error [Solved]

“E: Unable to locate package” Error [Solved]

The “E: Unable to locate package” error in Linux occurs when apt cannot find the package to install. This knowledge base provides step-by-step solutions to resolve this issue. It focuses on Debian-based distributions such as Ubuntu, which uses apt as a package manager.

To resolve the “E: Unable to locate package” error, first, we check for typos in the package name, and if no typos then update the package lists. If the issue persists, ensure to enable all necessary repositories and manually add any missing ones. Finally, verify the package’s availability for your distribution and fix any broken dependencies. This will identify the cause of the mistake and, if possible, offer a solution. Additionally, this knowledge base has added some more steps to maximize the possibility of identifying and resolving the issue.

Step 1: Double-check the package spelling

Ensure you spell the package name correctly. Even a small typo can prevent the package manager from finding the package.
For example, imagine trying to install a photo editing program. The program’s name might be “SuperPhotoEditor.” If you accidentally type “SuperPhotoEdtor” (missing the “i”), you won’t find the program. Even though it’s a small mistake, it prevents finding the program you want.

If you are unsure about the correct spelling of the package you are looking for, use the following command to find packages with similar names:

apt-cache search keyword

Replace the keyword in the command with a part of the package name or related keyword you are searching for!

Step 2: Update Package Lists

Software repositories are constantly updated with new packages or changes to existing ones. An outdated package list on your system won’t include information about recent additions or changes to existing packages. So, even if the package you want exists, your system won’t be able to find it because it’s looking at the old catalog (outdated list). Therefore sometimes updating the packaging list on your machine can solve the issue. You can update the packages list by running the command:

sudo apt update -y

This command fetches the latest package information from your repositories. You often find it to be the simplest fix.

Step 3: Enable All Repositories

When you run a command to install any particular packages, your machine fetches them only from the uncommented repos in your sources file. If a repo is commented or not included, you need to enable it by uncommenting or adding the specific repo to fix the issue.

To edit the sources file, open the file: /etc/apt/sources.list with your favorite text editor:

nano /etc/apt/sources.list

Make sure all the working repos in the file are uncommented. If not, uncomment it by removing the # from the beginning of the repos.

Ubuntu sources.list file

You can also add the missing repositories to the file during this step. A list of working repos is available on the webpage: https://www.veeble.org/kb/sources-list-file-urls-ubuntu/
After adding the repos, make sure to update again to refresh the package database by executing:

sudo apt update

Step 4: Check Package Availability

Package developers often create packages that are compatible with specific operating system versions. This is because the package might rely on certain features or libraries that only exist in those OS versions. Therefore checking the package availability is crucial if an error: “E: Unable to locate package” occurred during any package installation.
To verify if the package is available for your distribution version, run the command:

apt-cache search package-name

Replace “package-name” with the name of the package. If it’s listed, it means the package is available.

Step 5: Update and Upgrade

An outdated system can result in the error: “E: Unable to locate package”. To resolve this, you should update and upgrade the current OS, which can solve the error if outdated software causes it.

sudo apt update
sudo apt upgrade

This ensures your system and packages are up-to-date.

Step 6: Fix Broken Dependencies

When you install a software program (package), it often relies on other software components (dependencies) to function properly. If these dependencies are not present or have some issues, your system might encounter issues while installing packages that need them. Even though the specific package you want might technically be available, the dependency issues prevent your system from finding a valid installation path that satisfies all requirements. To fix it, running the below command will help:

sudo apt --fix-broken install

Step 7: Check If the Package is Available for your OS Version

Sometimes, your specific OS version might not have a package available. To check its availability, visit the Ubuntu Packages Search. Enter the package name in the search bar and select your Ubuntu version from the dropdown menu. This shows if your OS version has the package available and provides instructions on how to install it.

For that first, you need to know your current OS details for the search. This can be checked with the following command:

cat /etc/os-release

This command will list all the details you require to search the package on the Ubuntu Packages Search website.

cat /etc/os-release command

With the details, visit the website: https://packages.ubuntu.com/?ref=itsfoss.com and then enter the package name you are searching for in the field: Keyword.

Followed by ticking the checkbox: “Only show exact matches” and choosing the right distribution from the field: Distribution, click the “Search” button.

  1. If you find no results, your distribution doesn’t have the package you are looking for. Then you might check for any alternate solutions available on the internet for installing packages on your system other than through APT.
  1. If you find results for your distribution; then open the “Software & Updates” application on your machine and tick all checkboxes under “Downloadable from the Internet” under the section “Ubuntu Software” and then click “Close”.

Subsequently, update the system again with the command “sudo apt update” and then install your package again.

If you have only command-line access, then this error can be fixed from the Step 3 itself by adding all the repos to the sources.list file!

Step 8: Reinstall Package Manager

If all else fails, and you’ve exhausted other troubleshooting options, reinstalling the package manager might be a last resort. You can do this by the following command:

sudo apt-get install --reinstall apt


Following these steps should resolve the “E: Unable to locate package” error. If the issue persists, consider checking online forums or the official documentation for further assistance.

Also Read:

Ubuntu sources.list URLs: All Versions
Scroll to Top