This guide walks you through installing software on Ubuntu and fixing the most common dependency errors, such as unmet dependencies, broken packages, and E: Unable to correct problems. You’ll learn the standard commands, how to repair a broken package manager state, and what to do when a package refuses to install.
What You’ll Need
- A Ubuntu system (22.04, 24.04, or similar) with an internet connection.
- A user account with
sudoprivileges (you’ll be prompted for your password). - Basic comfort with the terminal — you can open it with Ctrl+Alt+T.
Step-by-Step
- Update your package lists. Run
sudo apt update. This refreshes the list of available packages and their dependencies from the repositories. If this fails with a network error, check your internet connection first. - Upgrade installed packages. Run
sudo apt upgrade. This brings all currently installed packages to their latest versions, which often resolves dependency mismatches caused by partial updates. - Install the package normally. Use
sudo apt install [package-name]. Replace[package-name]with the actual package, e.g.,sudo apt install vlc. If it installs without errors, you’re done. - If you see a dependency error, try fixing broken packages. Run
sudo apt --fix-broken install. This command tells apt to correct any broken dependencies, often by installing missing packages or removing conflicting ones. Review the changes it proposes before confirming with Y. - Clean up the package cache. Run
sudo apt cleanand thensudo apt autoclean. These remove downloaded package files that may be corrupted or incomplete, which can cause dependency issues. - Reconfigure any partially configured packages. Run
sudo dpkg --configure -a. This finishes any interrupted package configurations. It’s a common fix after a power loss or a crash during installation. - If the error persists, try installing with the
-fflag. Runsudo apt install -f [package-name]. This is an alias for--fix-brokenand can be used directly with the install command. - Check for held packages. Run
apt-mark showhold. If a package is listed, it’s being held back from updates. You can unhold it withsudo apt-mark unhold [package-name], then try the install again. - Consider using a different repository. If the package is not in the standard Ubuntu repositories, you may need to add a PPA or a third-party repository. Use
sudo add-apt-repository ppa:some/ppaand thensudo apt update. Only use repositories you trust. - As a last resort, remove and reinstall the package. Run
sudo apt remove --purge [package-name]to completely remove the package and its configuration files, thensudo apt install [package-name]to install it fresh.
Common Mistakes
- Mixing package managers. Using
pip,npm, orsnapto install software that should be managed byaptcan create conflicts. Stick to one manager per package. - Ignoring the
apt updatestep. Installing without updating first often leads to “package not found” or dependency errors because the package list is outdated. - Running
apt upgradeinstead ofapt dist-upgrade. For major version upgrades,dist-upgradehandles dependency changes more aggressively, but it can also remove packages. Use it carefully. - Forgetting to review proposed changes. When apt asks to remove or install extra packages, always read the list. Blindly accepting can remove software you need.
- Using
sudowithpip. Installing Python packages withsudo pipcan overwrite system files and break dependencies. Use a virtual environment instead.
Tips
- Use
aptinstead ofapt-get. Theaptcommand is more user-friendly and provides better progress bars and messages. - Keep your system updated regularly. Run
sudo apt update && sudo apt upgradeweekly to prevent dependency rot. - Read error messages carefully. They often tell you exactly which package is missing or conflicting.
- Use
apt-cache depends [package]to see a package’s dependencies before installing. This helps you anticipate issues. - If you’re trying to install a .deb file, use
sudo apt install ./file.deb. This will automatically fetch and install dependencies from the repositories.
Troubleshooting
If the steps above don’t resolve the issue, try these targeted fixes:
- Error: “E: Unmet dependencies. Try ‘apt –fix-broken install'” — Run
sudo apt --fix-broken installfirst. If that fails, runsudo dpkg --configure -aand thensudo apt --fix-broken installagain. - Error: “E: Could not get lock /var/lib/dpkg/lock” — Another process (like Software Updater) is using apt. Wait for it to finish, or close it. If it’s stuck, run
sudo pkill aptandsudo pkill dpkg, then try again. - Error: “Package has no installation candidate” — The package is not in your repositories. Check the spelling, enable the
universerepository withsudo add-apt-repository universe, or add a PPA. - Error: “The following packages have been kept back” — This is normal. Run
sudo apt dist-upgradeto upgrade them, but be aware it may remove packages. - Error: “dpkg: error processing package …” — Try
sudo dpkg --remove --force-remove-reinstreq [package]to remove a broken package, then reinstall it. - If nothing works, check for a system update. Run
sudo do-release-upgradeto upgrade to a newer Ubuntu release, which may fix underlying dependency issues.
Frequently Asked Questions
What does “unmet dependencies” mean?
It means the package you’re trying to install requires another package (or a specific version) that isn’t installed or is too old. Apt tries to resolve this, but sometimes it can’t.
Can I force install a package ignoring dependencies?
Yes, with sudo apt install --ignore-missing [package], but this is risky. The package may not work correctly, and you could break other software. Only use it as a temporary measure.
What is the difference between apt and apt-get?
apt is a newer, more user-friendly front-end to apt-get. Both do the same thing, but apt has better output and some extra commands like apt list.
Why does apt sometimes want to remove packages I want to keep?
This happens when a package’s dependencies conflict with installed packages. Apt proposes a solution that removes the conflicting package to satisfy the new one. Review the list carefully before confirming.
How do I install a package from a .deb file?
Use sudo apt install ./package.deb (note the ./). This will install the package and automatically fetch its dependencies from the repositories.
What should I do if a PPA causes dependency issues?
Remove the PPA with sudo add-apt-repository --remove ppa:some/ppa, then run sudo apt update and sudo apt --fix-broken install to repair any damage.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Change Google Text-to-Speech Voice on Android
- How to Adjust Volume Levels on a Windows PC
- Reset Chrome Sync to Fix Problems
- Fix Mouse Not Working in Windows 11
- Fix Windows Defender Failed to Initialize Error
- App Installation History Mac OS X: How to View It