我在使用 Debian 12。我在使用 apt 安装 python 库(numpy、pandas、sklearn)时犯了一个新手错误,现在每当我尝试安装或卸载任何东西时都会出现此错误。
安装时
thedude@192:~$ sudo apt install sl
[sudo] password for thedude:
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:
python3-bottleneck : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
python3-contourpy : Depends: python3-numpy but it is not going to be installed
python3-matplotlib : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
python3-numexpr : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
python3-pandas : Depends: python3-numpy but it is not going to be installed
Depends: python3-numpy (>= 1:1.18.5~) but it is not going to be installed or
python3 (< 3.10) but 3.11.2-1+b1 is to be installed
python3-pandas-lib : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
Recommends: python3-numba but it is not going to be installed
python3-pythran : Depends: python3-numpy but it is not going to be installed
python3-scipy : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
python3-sklearn : Depends: python3-numpy but it is not going to be installed
python3-sklearn-lib : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
python3-tables : Depends: python3-numpy but it is not going to be installed
python3-tables-lib : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
卸载时:
thedude@192:~$ sudo apt remove python3-numpy
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Package 'python3-numpy' is not installed, so not removed
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
python3-bottleneck : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
python3-contourpy : Depends: python3-numpy but it is not going to be installed
python3-matplotlib : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
python3-numexpr : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
python3-pandas : Depends: python3-numpy but it is not going to be installed
Depends: python3-numpy (>= 1:1.18.5~) but it is not going to be installed or
python3 (< 3.10) but 3.11.2-1+b1 is to be installed
python3-pandas-lib : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
Recommends: python3-numba but it is not going to be installed
python3-pythran : Depends: python3-numpy but it is not going to be installed
python3-scipy : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
python3-sklearn : Depends: python3-numpy but it is not going to be installed
python3-sklearn-lib : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
python3-tables : Depends: python3-numpy but it is not going to be installed
python3-tables-lib : Depends: python3-numpy (>= 1:1.22.0) but it is not going to be installed
Depends: python3-numpy-abi9
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
我apt fix-broken install
按照错误信息提示的那样尝试了。
thedude@192:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
fonts-lato icu-devtools libclang-cpp14 libffi-dev libicu-dev libllvm14
libncurses-dev libpfm4 libtinfo-dev libxml2-dev libz3-dev
llvm-14-linker-tools llvm-14-runtime llvm-14-tools nss-plugin-pem
python3-yaml sphinx-rtd-theme-common
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
python3-numpy
Suggested packages:
gfortran
The following NEW packages will be installed:
python3-numpy
0 upgraded, 1 newly installed, 0 to remove and 27 not upgraded.
Need to get 5,209 kB of archives.
After this operation, 28.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Err:1 http://deb.debian.org/debian bookworm/main amd64 python3-numpy amd64 1:1.24.2-1
404 Not Found [IP: 146.75.54.132 80]
E: Failed to fetch http://deb.debian.org/debian/pool/main/n/numpy/python3-numpy_1.24.2-1_amd64.deb 404 Not Found [IP: 146.75.54.132 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
我的理解是,产生错误的库是numpy。我发现它是通过键入以下内容安装的:
thedude@192:~$ sudo apt list python3-numpy
Listing... Done
python3-numpy/stable 1:1.24.2-1 amd64
但如图所示,我无法删除它。我尝试过更新,也--fix-missing
尝试过autoremove
thedude@192:~$ sudo apt --fix-broken install --fix-missing
[sudo] password for thedude:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
fonts-lato icu-devtools libclang-cpp14 libffi-dev libicu-dev libllvm14
libncurses-dev libpfm4 libtinfo-dev libxml2-dev libz3-dev
llvm-14-linker-tools llvm-14-runtime llvm-14-tools nss-plugin-pem
python3-yaml sphinx-rtd-theme-common
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
python3-numpy
Suggested packages:
gfortran
The following NEW packages will be installed:
python3-numpy
0 upgraded, 1 newly installed, 0 to remove and 27 not upgraded.
Need to get 5,209 kB of archives.
After this operation, 28.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Err:1 http://deb.debian.org/debian bookworm/main amd64 python3-numpy amd64 1:1.24.2-1
404 Not Found [IP: 146.75.54.132 80]
Unable to correct missing packages.
E: Failed to fetch http://deb.debian.org/debian/pool/main/n/numpy/python3-numpy_1.24.2-1_amd64.deb 404 Not Found [IP: 146.75.54.132 80]
E: Aborting install.
尝试过,update
效果很好,但没有什么区别。
我能做些什么来解决这个问题?
感谢@Stephen Kitt在评论中提出这个答案。我解决了这个问题
“404 Not Found” 错误的本质。这是一个 HTTP 状态代码,表示在服务器上找不到请求的资源。在 apt-get 上下文中,这意味着您尝试访问的包未在存储库服务器中找到。
运行
sudo apt update
然后再次尝试安装python3-numpy
。在安装软件包之前运行
sudo apt update
也是一个好习惯。sudo apt upgrade