The following packages have unmet dependencies!
I am writing this because I am very confused about installing PostgreSQL 9.3 on my Ubuntu 14.04. First I need it for my Python/Django development, and I ran into the problem when I tried to install it. Now I have this error and it is driving me crazy:
The following packages have unmet dependencies:
postgresql-9.3 : Depends: postgresql-client-9.3 but it is not going to be installed
Depends: postgresql-common (>= 142~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.I have found some solutions online (How do I resolve unmet dependencies after adding a PPA?), and I did everything to the Preventive Measures part, because I have had some broken packages problem, and again after I had this error show to me again.
The second thing I have followed the official PostgreSQL installing tutorial (), and I have had duplicated repositories, but I have deleted them and I have added a fresh one but still this error.
16 Answers
You can install the package using.
make sure the repo sources are up to date
sudo apt-get updateTo Install the package.
sudo apt-get install packagenameOnce the package determines that you have some missing dependencies, run the following command to fix broken or missing dependencies.
sudo apt-get install -fAbove command will only download the missing dependencies if you have already installed the package.
3I know I'm a bit late, but none of the above solutions worked for me. What really solved my problem was to use aptitude instead of apt-get. aptitude will suggest resolutions to the problem.
Simply run these:
sudo apt-get install aptitude
sudo aptitude install <package-name>aptitude will suggest dependencies resolution for you e.g:
The following actions will resolve these dependencies:
Keep the following packages at their current version:
1) libyaml-dev [Not Installed]
Accept this solution? [Y/n/q/? (n)
The following actions will resolve these dependencies:
Downgrade the following packages:
1) libyaml-0-2 [0.1.4-3ubuntu3.1 (now) -> 0.1.4-3ubuntu3 (trusty)]
Accept this solution? [Y/n/q/?] (Y)as discussed in this post.
2Sometimes the dependencies that need fixing are unrelated to the program you are trying to install. In my case it was giving off this error:
The following have unmet dependecies
shashlik : Depends: libc6-i386 but it is not going to be installed
Depends: lib32gcc1 but it is not going to be installed
Depends: lib32z1 but it is not going to be installed
It turned out that I had tried to install a program called "Shashlik" and the installation had failed. So I ran the code:
sudo apt-get --purge remove shashlikAnd then I ran:
sudo apt install autoconfThis seemed to fix the error as my program then installed. I am not sure how much the second command helped but I put it there in case it was necessary for the solution to work.
2Let me share with other people my experience with installing postgresql-9.3. First of all I have been struggling with this for about 4/5 days, and I finally manage to do it.
All went wrong with these nasty errors I have shared in my first post, as I have tried to google it and discover that people have more less the same error, or struggling to solve a similar one.
Long story short, you have a very nice answer here how to resolve unmet packages:
How do I resolve unmet dependencies after adding a PPA?
My mistake was that I have made duplicated repository, and the answer in this link solved that, this
command sudo apt-get install -f just made another error, you must do this manually, at least I did it (read to the section Preventive Measures, but you could read to the end, it is an imba post).
Second I manage to google this post from official PostgreSQL page (this is the error people usually have when they are struggling with installation of postgresql), this led me to
, this is the proper way for adding PostgreSQL Packages to your system, just read it and do it step by step.
Third step are series of commands provided in the @vembutech post:
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install postgresql-9.3 postgresql-contrib-9.3 0 First of all you've to find the package that is broken. Let's say you're getting following error,
The following packages have unmet dependencies: libpython3.9 : Depends: libpython3.9-stdlib (= 3.9.5-3~20.04.1) but 3.9.4-1+bionic1 is to be installedYou've to manually remove the files of broken package.
To get the list of the files you can run
sudo ls –l /var/lib/dpkg/info | grep -i libpython3.9-devReplace libpython3.9-dev with your own package name.
Output
libpython3.9-dev:amd64.list
libpython3.9-dev:amd64.md5sumsNow, you can to discard these files.
sudo rm /var/lib/dpkg/info/python3.9-dev*Perform the same operations for the rest of packages.
Once it's done, you can run
sudo apt --fix-broken installThis time the above command should work fine.
Try by installing the with below command.
sudo apt-get install postgresql-common=151.pgdg12.4+1
sudo apt-get install postgresql-9.3 postgresql-contrib-9.3 2