I get the below error when I'm trying to install Postgres Data Base by running that command on Ubuntu OS sudo apt-get install postgresql-9.4
dpkg: error processing package postgresql-9.4 (--configure): subprocess installed post-installation script returned error exit status 2 dpkg: dependency problems prevent configuration of postgresql-contrib-9.4: postgresql-contrib-9.4 depends on postgresql-9.4 (= 9.4.11-1.pgdg16.04+1); however: Package postgresql-9.4 is not configured yet. dpkg: error processing package postgresql-contrib-9.4 (--configure): dependency problems - leaving unconfigured No apport report written because the error message indicates its a followup error from a previous failure. Errors were encountered while processing: postgresql-9.4 postgresql-contrib-9.4 E: Sub-process /usr/bin/dpkg returned an error code (1)
If you tried several solutions, you probably have some leftovers from that tries. To start from 'scratch' you have to uninstall everything and cleanup your system before trying anything:
sudo apt-get purge 'postgresql.*'
This will uninstall all packages and remove all config files. Note: this will also remove all database files from your system.
After that you have to check what repositories you have added to the system. Check /etc/apt/sources.list file and every other files in /etc/apt/sources.list.d/ directory.
Remove everything related to postgresql and 'pgdg'.
And finally, you can follow official postgresql manual here: https://wiki.postgresql.org/wiki/Apt