![为什么 apt-get Upgrade 只返回“以下软件包已被保留:python3-psycopg2”,而 apt update 显示它可以升级(如何升级)?](https://linux22.com/image/185902/%E4%B8%BA%E4%BB%80%E4%B9%88%20apt-get%20Upgrade%20%E5%8F%AA%E8%BF%94%E5%9B%9E%E2%80%9C%E4%BB%A5%E4%B8%8B%E8%BD%AF%E4%BB%B6%E5%8C%85%E5%B7%B2%E8%A2%AB%E4%BF%9D%E7%95%99%EF%BC%9Apython3-psycopg2%E2%80%9D%EF%BC%8C%E8%80%8C%20apt%20update%20%E6%98%BE%E7%A4%BA%E5%AE%83%E5%8F%AF%E4%BB%A5%E5%8D%87%E7%BA%A7%EF%BC%88%E5%A6%82%E4%BD%95%E5%8D%87%E7%BA%A7%EF%BC%89%EF%BC%9F%20.png)
我使用的是 Debian10/KDE,几个月前就保留了一个软件包。但是,当使用sudo apt update
而不是 时sudo apt-get update
,它会显示其他内容并允许查看“附加版本”。
这是为什么?这不应该也用 apt-get 显示吗?难道不应该简单地安装2.8.5版本吗? (为什么不行?怎么安装?)
sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
python3-psycopg2
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
sudo apt update
Reading package lists... Done
Building dependency tree
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
apt list --upgradable
Listing... Done
python3-psycopg2/stretch-pgdg 2.8.5-1~pgdg90+1 amd64 [upgradable from: 2.7.7-1]
N: There is 1 additional version. Please use the '-a' switch to see it
apt list --upgradable -a
Listing... Done
python3-psycopg2/stretch-pgdg 2.8.5-1~pgdg90+1 amd64 [upgradable from: 2.7.7-1]
python3-psycopg2/stable,now 2.7.7-1 amd64 [installed,upgradable to: 2.8.5-1~pgdg90+1]
尝试进一步调试:
apt policy python3-psycopg2
python3-psycopg2:
Installed: 2.7.7-1
Candidate: 2.8.5-1~pgdg90+1
Version table:
2.8.5-1~pgdg90+1 500
500 http://apt.postgresql.org/pub/repos/apt stretch-pgdg/main amd64 Packages
*** 2.7.7-1 500
500 http://ftp.XX.debian.org/debian buster/main amd64 Packages
100 /var/lib/dpkg/status
sudo apt install python3-psycopg2
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:
python3-psycopg2 : Depends: python3 (< 3.6) but 3.7.3-1 is to be installed
E: Unable to correct problems, you have held broken packages.
与链接的问题不同,通常的问题sudo apt-get --with-new-pkgs upgrade
在这里不起作用:
sudo apt-get --with-new-pkgs upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
无论解决方案是什么:运行时至少应该有一个提示sudo apt-get upgrade
来安装或不安装该新版本。
答案1
在您的 Postgresql 存储库中将stretch
代号更改为buster
:
sudo sed -i 's/stretch/buster/' /etc/apt/sources.list.d/pgdg.list
然后运行:
sudo apt update
sudo apt upgrade
python3-psycopg2/stretch-pgdg 2.8.5-1~pgdg90+1 amd64 [可升级自:2.7.7-1]
debian 存储库提供的安装版本python3-psycopg2
需要升级为2.8.5-1~pgdg90+1
postgresql 存储库提供的版本。但在升级之前,您需要设置正确的存储库,该存储库指向 debian Buster 而不是Stretch
当前设置的。