dist 升级后 apt (debian 6.1.20-1) 损坏

dist 升级后 apt (debian 6.1.20-1) 损坏

最近做了一次分布式升级,我设法进入了一些完全崩溃的状态。

% sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 hplip : Depends: hplip-data (= 3.22.10+dfsg0-2) but 3.22.6+dfsg0-1 is installed
         Depends: printer-driver-hpcups (= 3.22.10+dfsg0-2) but 3.22.6+dfsg0-1 is installed
         Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 libpython3-dev : Depends: libpython3.11-dev (>= 3.11.2-1~) but it is not installed
 mercurial : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-apt : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-cairo : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-cffi-backend : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-dbus : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-dev : Depends: python3 (= 3.11.2-1) but 3.10.6-1 is installed
               Depends: python3.11-dev (>= 3.11.2-1~) but it is not installed
               Depends: python3-distutils (>= 3.11.2-1~) but 3.10.7-1 is installed
 python3-gi : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-gi-cairo : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-lxml : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-markupsafe : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-pil : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-pycurl : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-renderpm : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-reportlab-accel : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
 python3-venv : Depends: python3.11-venv (>= 3.11.2-1~) but it is not installed
                Depends: python3 (= 3.11.2-1) but 3.10.6-1 is installed
                Depends: python3-distutils (>= 3.11.2-1~) but 3.10.7-1 is installed
 python3-yaml : Depends: python3 (>= 3.11~) but 3.10.6-1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

当我尝试运行 apt install -f 时:

% sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  hplip-data libpython3-stdlib libpython3.11-dev printer-driver-hpcups python3 python3-distutils python3-lib2to3 python3-minimal python3-numpy python3.11-dev
  python3.11-venv
Suggested packages:
  hplip-doc python3-doc python3-tk python3-pytest
The following packages will be REMOVED:
  python3.10-venv
The following NEW packages will be installed:
  libpython3.11-dev python3.11-dev python3.11-venv
The following packages will be upgraded:
  hplip-data libpython3-stdlib printer-driver-hpcups python3 python3-distutils python3-lib2to3 python3-minimal python3-numpy
8 upgraded, 3 newly installed, 1 to remove and 4 not upgraded.
31 not fully installed or removed.
Need to get 0 B/17.8 MB of archives.
After this operation, 36.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Traceback (most recent call last):
  File "/usr/bin/apt-listchanges", line 29, in <module>
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'
(Reading database ... 410707 files and directories currently installed.)
Preparing to unpack .../python3-numpy_1%3a1.24.2-1_amd64.deb ...
Unpacking python3-numpy (1:1.24.2-1) over (1:1.21.5-1+b1) ...
dpkg: error processing archive /var/cache/apt/archives/python3-numpy_1%3a1.24.2-1_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/f2py', which is also in package python-numpy 1:1.16.2-1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/python3-numpy_1%3a1.24.2-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

基于https://stackoverflow.com/questions/13708180/python-dev-installation-error-importerror-no-module-named-apt-pkg 我试过:

% cd /usr/lib/python3/dist-packages 
% sudo ln -s apt_pkg.cpython-311-x86_64-linux-gnu.so apt_pkg.so
% sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  hplip-data libpython3-stdlib libpython3.11-dev printer-driver-hpcups python3 python3-distutils python3-lib2to3 python3-minimal python3-numpy python3.11-dev
  python3.11-venv
Suggested packages:
  hplip-doc python3-doc python3-tk python3-pytest
The following packages will be REMOVED:
  python3.10-venv
The following NEW packages will be installed:
  libpython3.11-dev python3.11-dev python3.11-venv
The following packages will be upgraded:
  hplip-data libpython3-stdlib printer-driver-hpcups python3 python3-distutils python3-lib2to3 python3-minimal python3-numpy
8 upgraded, 3 newly installed, 1 to remove and 4 not upgraded.
31 not fully installed or removed.
Need to get 0 B/17.8 MB of archives.
After this operation, 36.4 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Reading changelogs... Done
(Reading database ... 410707 files and directories currently installed.)
Preparing to unpack .../python3-numpy_1%3a1.24.2-1_amd64.deb ...
Unpacking python3-numpy (1:1.24.2-1) over (1:1.21.5-1+b1) ...
dpkg: error processing archive /var/cache/apt/archives/python3-numpy_1%3a1.24.2-1_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/f2py', which is also in package python-numpy 1:1.16.2-1
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
 /var/cache/apt/archives/python3-numpy_1%3a1.24.2-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我得到了同样的错误

% sudo mv /usr/bin/python3 /usr/bin/python3.old
% sudo ln -s /usr/bin/python3.11 /usr/bin/python3
% sudo apt --fix-broken install

(结合上述和单独)

我不知道从这里该去哪里。

答案1

问题归结为

dpkg: error processing archive /var/cache/apt/archives/python3-numpy_1%3a1.24.2-1_amd64.deb (--unpack):
 trying to overwrite '/usr/bin/f2py', which is also in package python-numpy 1:1.16.2-1

Python 2python-numpy软件包在 Debian 11 中被删除;你也应该删除它:

sudo dpkg --purge python-numpy

相关内容