系统信息:Ubuntu 18.04.4 LTS(GNU/Linux 4.15.0-88-generic x86_64)
当我尝试使用 apt 安装或卸载时出现错误:
trever@server:~$ sudo apt-get install ctorrent
[sudo] password for trever:
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
python-pkg-resources : Depends: python:any (< 2.8)
Depends: python:any (>= 2.7.5-5~)
python-virtualenv : Depends: python but it is not going to be installed
Recommends: virtualenv but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
当我尝试运行它建议的命令时,我收到另一个错误,并且我只是在依赖项中循环往复:
trever@server:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
python
Suggested packages:
python-doc python-tk
The following NEW packages will be installed:
python
0 upgraded, 1 newly installed, 0 to remove and 27 not upgraded.
7 not fully installed or removed.
Need to get 0 B/140 kB of archives.
After this operation, 639 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python2.7-minimal (2.7.17-1~18.04) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
/usr/bin/python2.7: can't open file '/usr/lib/python2.7/py_compile.py': [Errno 2] No such file or directory
dpkg: error processing package python2.7-minimal (--configure):
installed python2.7-minimal package post-installation script subprocess returned error exit status 2
dpkg: dependency problems prevent configuration of python-minimal:
python-minimal depends on python2.7-minimal (>= 2.7.15~rc1-1~); however:
Package python2.7-minimal is not configured yet.
dpkg: error processing package python-minimal (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python2.7-minimal
python-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)
我该如何修复?我的 Python 中有些东西严重损坏,现在也影响了系统的其他部分。
编辑:
trever@server:/usr/lib$ sudo dpkg --configure -a
Setting up python3.8 (3.8.2-1+bionic1) ...
Could not find platform independent libraries <prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = '/usr/bin/python3.8'
isolated = 0
environment = 0
user site = 1
import site = 0
sys._base_executable = '/usr/bin/python3.8'
sys.base_prefix = '/usr'
sys.base_exec_prefix = '/usr'
sys.executable = '/usr/bin/python3.8'
sys.prefix = '/usr'
sys.exec_prefix = '/usr'
sys.path = [
'/usr/lib/python38.zip',
'/usr/lib/python3.8',
'/usr/lib/python3.8/lib-dynload',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00007f498c8b3740 (most recent call first):
<no Python frame>
dpkg: error processing package python3.8 (--configure):
installed python3.8 package post-installation script subprocess returned error exit status 1
Setting up python3-virtualenv (15.1.0+ds-1.1) ...
[Errno 2] No such file or directory: '/usr/lib/python3/dist-packages/virtualenv.py'
dpkg: error processing package python3-virtualenv (--configure):
installed python3-virtualenv package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
python3.8
python3-virtualenv
答案1
如果您尚未使用 升级您的系统sudo apt-get upgrade
,请这样做。然后,我建议您尝试安装您的文件。此外,如果sudo apt-get upgrade
不行,请使用sudo dpkg --configure -a
并重试。确保在配置 dpkg 后执行升级命令。然后您应该能够安装文件。如果这些都不起作用,请尝试此网站上的一些操作:https://www.iasptk.com/ubuntu-fix-broken-package-best-solution
它有可能的解决方案。