无法在 Ubuntu 15.04 上安装 postgresql 9.6

无法在 Ubuntu 15.04 上安装 postgresql 9.6

要在 Ubuntu 15.04 上安装 postgresql 9.6,我按照以下步骤进行操作这里这里

我在安装时收到此错误。

Preparing to unpack .../postgresql-contrib_9.6+180.pgdg16.04+1_all.deb ...
Unpacking postgresql-contrib (9.6+180.pgdg16.04+1) ...
Setting up postgresql-9.6 (9.6.2-1.pgdg16.04+1) ...
Can't locate PgCommon.pm in @INC (you may need to install the PgCommon 
module) (@INC contains: /usr/share/postgresql-common 
/usr/local/lib/perl5/site_perl/5.24.1/x86_64-linux 
/usr/local/lib/perl5/site_perl/5.24.1 
/usr/local/lib/perl5/5.24.1/x86_64-linux /usr/local/lib/perl5/5.24.1 .).
BEGIN failed--compilation aborted.
dpkg: error processing package postgresql-9.6 (--configure):
subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of postgresql-contrib-9.6:
postgresql-contrib-9.6 depends on postgresql-9.6 (= 9.6.2-1.pgdg16.04+1); however:
Package postgresql-9.6 is not configured yet.

它说无法找到 PgCommon.pm。我对 perl 模块不太熟悉。所以我尝试按照以下步骤安装 PgCommon,但没有成功。

cpan
cpan >> install PgCommon

请帮我安装。谢谢

输出sudo apt-cache madison postgresql | grep -vi sources

postgresql | 9.6+180.pgdg16.04+1 | http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg/main amd64 Packages
postgresql | 9.4+166bzr2 | http://in.archive.ubuntu.com/ubuntu/ vivid/main amd64 Packages

答案1

以下是安装 postgresql 的简单终端命令,请尝试这个

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

答案2

我已经在我的机器上解决了这个问题。此错误阻止了安装:

Can't locate PgCommon.pm in @INC (you may need to install the PgCommon 
module) (@INC contains: /usr/share/postgresql-common 
/usr/local/lib/perl5/site_perl/5.24.1/x86_64-linux 
/usr/local/lib/perl5/site_perl/5.24.1 
/usr/local/lib/perl5/5.24.1/x86_64-linux /usr/local/lib/perl5/5.24.1 .)

我发现由于 perl 依赖性,安装失败。因此我运行了以下命令。

which perl
>>>> /usr/local/lib/perl

经过一番谷歌搜索,我发现实际路径应该是/usr/bin/perl成功安装 postgres 的路径。Perl 在我的系统上安装了不止一次。这就是问题所在。所以我删除了目录:

sudo rm -rf /usr/local/lib/perl
sudo rm -rf /usr/local/bin/perl

之后我运行以下命令成功安装 postgres。

sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | 
sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6

答案3

一直停留在 postgresql-client-9.6:依赖:libpq5(>= 9.6.10)但需要安装 9.5.14-0ubuntu0.16.04 几天。

尝试了几个类似上述的解决方案,但总是出现上述错误。最后通过

sudo aptitude install libpq5=11.0-1.pgdg16.04+2
sudo apt install -f postgresql-9.6 postgresql-client-9.6 postgresql-contrib-9.6

相关内容