我尝试安装 postgres:我写了这个:
sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
然后是这个:
jonsdirewolf@DESKTOP-GNM7V6T:~$ sudo apt-get install postgresql-common
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-common : Depends: init-system-helpers (>= 1.18~) but 1.14ubuntu1 is to be installed
E: Unable to correct problems, you have held broken packages.
jonsdirewolf@DESKTOP-GNM7V6T:~$ sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
gpg: no valid OpenPGP data found.
我使用的是windows 10内置的wsl linux环境
jonsdirewolf@DESKTOP-GNM7V6T:~$ uname -a
Linux DESKTOP-GNM7V6T 3.4.0+ #1 PREEMPT Thu Aug 1 17:06:05 CST 2013 x86_64 x86_64 x86_64 GNU/Linux
答案1
你需要更换
sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ xenial-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
和
sudo sh -c "echo 'deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main' > /etc/apt/sources.list.d/pgdg.list"
因为正如您从链接地址中看到的那样,它适用于 16.04 xenial (您的链接包含“xenial”)