我有一个用于多种用途的 Debian 服务器的问题。昨天,我尝试apt-get update / upgrade
像往常一样简单地升级我的软件包,但发现一切都被破坏了:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
owncloud owncloud-config-apache owncloud-server
The following packages will be upgraded:
python-apt
1 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
2 not fully installed or removed.
Need to get 0 B/171 kB of archives.
After this operation, 47.1 kB disk space will be freed.
Do you want to continue? [Y/n]
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to a fallback locale ("en_US.UTF-8").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
(Reading database ... 83301 files and directories currently installed.)
Preparing to unpack .../python-apt_0.9.3.12_amd64.deb ...
/var/lib/dpkg/info/python-apt.prerm: /usr/bin/pyclean: /usr/bin/python: bad interpreter: No such file or directory
dpkg: warning: subprocess old pre-removal script returned error exit status 126
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/prerm: /usr/bin/pyclean: /usr/bin/python: bad interpreter: No such file or directory
dpkg: error processing archive /var/cache/apt/archives/python-apt_0.9.3.12_amd64.deb (--unpack):
subprocess new pre-removal script returned error exit status 126
/var/lib/dpkg/info/python-apt.postinst: /usr/bin/pycompile: /usr/bin/python: bad interpreter: No such file or directory
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 126
Errors were encountered while processing:
/var/cache/apt/archives/python-apt_0.9.3.12_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
从那时起,我尝试应用一系列解决方案,包括dpkg --audit
此处和其他社区帮助网站上针对类似问题的建议以及建议的解决方案,但均无济于事。
似乎即使在修复了 perl 提到的区域设置问题之后,如果我退出 ssh 会话并打开一个新会话,它也会再次出现。
我有什么想法可以解决这个问题吗? (除了从头开始重新安装,如果可能的话我宁愿避免。)
谢谢。
编辑(更新):根据@Gilles的要求,这是结果ls -l /usr/bin/python; ls -lL /usr/bin/python; dpkg -S /usr/bin/python
ls: cannot access /usr/bin/python: No such file or directory
ls: cannot access /usr/bin/python: No such file or directory
python-minimal: /usr/bin/python
我不记得手动更改过 python 设置。
答案1
/var/lib/dpkg/info/python-apt.postinst: /usr/bin/pycompile: /usr/bin/python: bad interpreter: No such file or directory
该错误表明它/usr/bin/python
在某些方面被破坏了。大多数 Python 脚本将无法运行。
python-apt
安装该包后,它会运行 Python 脚本。此操作失败,因此无法完成软件包的安装。尽管即使某个包失败,APT 也可以继续处理其他包,但这可能需要运行apt-get -f install
几次,并且可能会阻止重新调整依赖项的升级。无论如何,一个损坏的 Python 将会损坏很多软件。
$ ls -l /usr/bin/python ls: cannot access /usr/bin/python: No such file or directory $ dpkg -S /usr/bin/python python-minimal: /usr/bin/python
/usr/bin/python
根本不存在。但打包系统认为已经安装了。
重新安装包含以下内容的软件包/usr/bin/python
:
sudo apt-get --reinstall install python-minimal
sudo apt-get -f install
如果缺少/usr/bin/python
是唯一的问题,则应该修复您的系统。但无论是什么导致/usr/bin/python
消失,都可能引发其他问题。
尝试找出可能导致/usr/bin/python
消失的原因。如果您使用dpkg
并apt
管理包,通常不会发生这种情况。确保如果您在不使用包管理器的情况下安装任何软件,它会位于/opt
或下/usr/local
,而不是直接位于 下/usr
。