无法重新安装postgresql - apt-get依赖项错误

时间:2015-02-08 23:18:39

标签: postgresql apt

我之前可以安装postgresql,但后来又卸载并重新安装,现在如果我尝试的话:

sudo apt-get update
sudo apt-get install postgresql postgresql-contrib

这将出现:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 postgresql : Depends: postgresql-9.4 but it is not going to be installed
 postgresql-contrib : Depends: postgresql-contrib-9.4 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

这里有什么问题?

我想从头开始改造。所以我之前做过的事情:

sudo apt-get --purge remove postgresql
sudo rm -rf /var/lib/postgresql/ 
sudo rm -rf /var/log/postgresql/ 
sudo rm -rf /etc/postgresql/

2 个答案:

答案 0 :(得分:2)

您的数据库可能已损坏。尝试:sudo apt-get --fix-broken

或者,可能是留下的文件与postgresql版本9.4冲突。如果可以,请安装之前使用的postgresql版本,然后使用dpkg-query -L <package_name>,您可以看到安装了哪些文件以及您可能留下的内容。

答案 1 :(得分:0)

运行以下内容。

sudo apt install aptitude&amp;&amp; sudo aptitude install postgresql postgresql-contrib