![apt-get install [package] 获取错误](https://linux22.com/image/1168642/apt-get%20install%20%5Bpackage%5D%20%E8%8E%B7%E5%8F%96%E9%94%99%E8%AF%AF%20.png)
当我发出以下命令时:
apt-get install ssh
我收到以下错误
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
base-files libedit2 libssl1.0.0 libxmuu1 ncurses-term openssh-client openssh-server openssh-sftp-server python3-certifi python3-chardet
python3-idna python3-pkg-resources python3-requests python3-six python3-urllib3 ssh-import-id wget xauth
Suggested packages:
keychain libpam-ssh monkeysphere ssh-askpass molly-guard rssh ufw python3-setuptools python3-cryptography python3-openssl python3-socks
The following NEW packages will be installed:
libedit2 libssl1.0.0 libxmuu1 ncurses-term openssh-client openssh-server openssh-sftp-server python3-certifi python3-chardet python3-idna
python3-pkg-resources python3-requests python3-six python3-urllib3 ssh ssh-import-id wget xauth
The following packages will be upgraded:
base-files
1 upgraded, 18 newly installed, 0 to remove and 12 not upgraded.
5 not fully installed or removed.
Need to get 0 B/3,343 kB of archives.
After this operation, 17.1 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
(Reading database ... 11001 files and directories currently installed.)
Preparing to unpack .../base-files_10.1ubuntu2.7_amd64.deb ...
dpkg-maintscript-helper: error: dpkg: error: unknown option --validate-version
Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;
Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
dpkg: error processing archive /var/cache/apt/archives/base-files_10.1ubuntu2.7_amd64.deb (--unpack):
subprocess new pre-installation script returned error exit status 1
dpkg-maintscript-helper: error: dpkg: error: unknown option --validate-version
Type dpkg --help for help about installing and deinstalling packages [*];
Use 'apt' or 'aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;
Options marked [*] produce a lot of output - pipe it through 'less' or 'more' !
dpkg: error while cleaning up:
subprocess new post-removal script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/base-files_10.1ubuntu2.7_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
然后我尝试:
dpkg --configure -a
结果如下:
Setting up python3 (3.6.7-1~18.04) ...
running python rtupdate hooks for python3.6...
dpkg-query: package 'dh-python' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
File "/usr/bin/py3clean", line 210, in <module>
main()
File "/usr/bin/py3clean", line 196, in main
pfiles = set(dpf.from_package(options.package))
File "/usr/share/python3/debpython/files.py", line 53, in from_package
raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of dh-python
error running python rtupdate hook dh-python
dpkg-query: package 'gedit' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
File "/usr/bin/py3clean", line 210, in <module>
main()
File "/usr/bin/py3clean", line 196, in main
pfiles = set(dpf.from_package(options.package))
File "/usr/share/python3/debpython/files.py", line 53, in from_package
raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of gedit
error running python rtupdate hook gedit
dpkg-query: package 'hplip-data' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
File "/usr/bin/py3clean", line 210, in <module>
main()
File "/usr/bin/py3clean", line 196, in main
pfiles = set(dpf.from_package(options.package))
File "/usr/share/python3/debpython/files.py", line 53, in from_package
raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of hplip-data
error running python rtupdate hook hplip-data
dpkg-query: package 'ibus-table' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
File "/usr/bin/py3clean", line 210, in <module>
main()
File "/usr/bin/py3clean", line 196, in main
pfiles = set(dpf.from_package(options.package))
File "/usr/share/python3/debpython/files.py", line 53, in from_package
raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of ibus-table
error running python rtupdate hook ibus-table
dpkg-query: package 'ibus' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
File "/usr/bin/py3clean", line 210, in <module>
main()
File "/usr/bin/py3clean", line 196, in main
pfiles = set(dpf.from_package(options.package))
File "/usr/share/python3/debpython/files.py", line 53, in from_package
raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of ibus
error running python rtupdate hook ibus
dpkg-query: package 'libglib2.0-dev-bin' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
File "/usr/bin/py3clean", line 210, in <module>
main()
File "/usr/bin/py3clean", line 196, in main
pfiles = set(dpf.from_package(options.package))
File "/usr/share/python3/debpython/files.py", line 53, in from_package
raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of libglib2.0-dev-bin
error running python rtupdate hook libglib2.0-dev-bin
dpkg-query: package 'python3-uno' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
File "/usr/bin/py3clean", line 210, in <module>
main()
File "/usr/bin/py3clean", line 196, in main
pfiles = set(dpf.from_package(options.package))
File "/usr/share/python3/debpython/files.py", line 53, in from_package
raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of python3-uno
error running python rtupdate hook python3-uno
dpkg-query: package 'rhythmbox-plugin-alternative-toolbar' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
File "/usr/bin/py3clean", line 210, in <module>
main()
File "/usr/bin/py3clean", line 196, in main
pfiles = set(dpf.from_package(options.package))
File "/usr/share/python3/debpython/files.py", line 53, in from_package
raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of rhythmbox-plugin-alternative-toolbar
error running python rtupdate hook rhythmbox-plugin-alternative-toolbar
dpkg-query: package 'rhythmbox-plugins' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
File "/usr/bin/py3clean", line 210, in <module>
main()
File "/usr/bin/py3clean", line 196, in main
pfiles = set(dpf.from_package(options.package))
File "/usr/share/python3/debpython/files.py", line 53, in from_package
raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of rhythmbox-plugins
error running python rtupdate hook rhythmbox-plugins
dpkg-query: package 'system-config-printer-common' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
File "/usr/bin/py3clean", line 210, in <module>
main()
File "/usr/bin/py3clean", line 196, in main
pfiles = set(dpf.from_package(options.package))
File "/usr/share/python3/debpython/files.py", line 53, in from_package
raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of system-config-printer-common
error running python rtupdate hook system-config-printer-common
dpkg-query: package 'system-config-printer' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
File "/usr/bin/py3clean", line 210, in <module>
main()
File "/usr/bin/py3clean", line 196, in main
pfiles = set(dpf.from_package(options.package))
File "/usr/share/python3/debpython/files.py", line 53, in from_package
raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of system-config-printer
error running python rtupdate hook system-config-printer
dpkg-query: package 'ubuntu-drivers-common' is not installed
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.
Traceback (most recent call last):
File "/usr/bin/py3clean", line 210, in <module>
main()
File "/usr/bin/py3clean", line 196, in main
pfiles = set(dpf.from_package(options.package))
File "/usr/share/python3/debpython/files.py", line 53, in from_package
raise Exception("cannot get content of %s" % package_name)
Exception: cannot get content of ubuntu-drivers-common
error running python rtupdate hook ubuntu-drivers-common
dpkg: error processing package python3 (--configure):
subprocess installed post-installation script returned error exit status 4
dpkg: dependency problems prevent configuration of python3-gi:
python3-gi depends on python3 (<< 3.7); however:
Package python3 is not configured yet.
python3-gi depends on python3 (>= 3.6~); however:
Package python3 is not configured yet.
python3-gi depends on python3:any (>= 3.3.2-2~); however:
Package python3 is not configured yet.
dpkg: error processing package python3-gi (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of networkd-dispatcher:
networkd-dispatcher depends on python3-gi; however:
Package python3-gi is not configured yet.
networkd-dispatcher depends on python3:any; however:
Package python3 is not configured yet.
dpkg: error processing package networkd-dispatcher (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python3-dbus:
python3-dbus depends on python3 (<< 3.7); however:
Package python3 is not configured yet.
python3-dbus depends on python3 (>= 3.6~); however:
Package python3 is not configured yet.
python3-dbus depends on python3:any (>= 3.4~); however:
Package python3 is not configured yet.
dpkg: error processing package python3-dbus (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python3
python3-gi
networkd-dispatcher
python3-dbus
然后在根模式下:我尝试以下命令:
python -V
我明白了:
Python 3.7.2
最后,无法按照网上的解决方案进行操作,因为当输入以“dkpg”和“apt”开头的任何命令时,我都会收到第一个错误。
我尝试从基础版本安装 dkpg,因此从以下位置下载最新版本snappy.debian.org 上的 dpkg 1.18.25 页面。
sudo dpkg -i dpkg_1.18.25_amd64.deb
然后我尝试使用 apt 命令,但再次出现错误。
答案1
理解这段文字的关键是dpkg: error: unknown option --validate-version
。摆脱那个蹩脚的 Python 版本 3.7.2 并使用(恢复)默认的 Python 2 版本,这堆错误消息就会消失。我可以说 python 3.7.2 不是默认版本,因为它不在任何当前支持的 Ubuntu 版本的默认存储库中,因此您必须手动或从 PPA 安装它。如果您需要更多信息,请评论以告知您正在使用的 Ubuntu 版本以及和sudo apt install python-all
的结果。which python3
which python3.7