尝试安装 pdfshuffler(来自 Debian repo)后,出现了与依赖性问题相关的错误。似乎需要 python-pypdf2 包,所以我尝试安装它,但收到相同的错误消息。在查找类似的问题后,我尝试使用 apt-get clean、install-f、autoremove 等,但它没有用,并且处理过程中遇到的错误列表不断增长。我留下了 apt-get Upgrade 后出现的错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
mendeleydesktop
0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded.
15 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up python-crypto (2.6.1-7) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 27, in <module>
import optparse
File "/usr/lib/python2.7/optparse.py", line 1557
print(self.get_usage(), file=file)
^
SyntaxError: invalid syntax
dpkg: error processing package python-crypto (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up python-wheel (0.29.0-2) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 27, in <module>
import optparse
File "/usr/lib/python2.7/optparse.py", line 1557
print(self.get_usage(), file=file)
^
SyntaxError: invalid syntax
dpkg: error processing package python-wheel (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up python-roman (2.0.0-2) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 27, in <module>
import optparse
File "/usr/lib/python2.7/optparse.py", line 1557
print(self.get_usage(), file=file)
^
SyntaxError: invalid syntax
dpkg: error processing package python-roman (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up python-pypdf2 (1.26.0-2) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 27, in <module>
import optparse
File "/usr/lib/python2.7/optparse.py", line 1557
print(self.get_usage(), file=file)
^
SyntaxError: invalid syntax
dpkg: error processing package python-pypdf2 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python-keyrings.alt:
python-keyrings.alt depends on python-crypto; however:
Package python-crypto is not configured yet.
dpkg: error processing package python-keyrings.alt (--configure):
dependency problems - leaving unconfigured
Setting up python-gi (3.22.0-2) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 27, in <module>
import optparse
File "/usr/lib/python2.7/optparse.py", line 1557
print(self.get_usage(), file=file)
^
SyntaxError: invalid syntax
dpkg: error processing package python-gi (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up python-epydoc (3.0.1+dfsg-14) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 27, in <module>
import optparse
File "/usr/lib/python2.7/optparse.py", line 1557
print(self.get_usage(), file=file)
^
SyntaxError: invalid syntax
dpkg: error processing package python-epydoc (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of pdfshuffler:
pdfshuffler depends on python-pypdf2 | python-pypdf (>= 1.10); however:
Package python-pypdf2 is not configured yet.
Package python-pypdf is not installed.
dpkg: error processing package pdfshuffler (--configure):
dependency problems - leaving unconfigured
Setting up python-dbus (1.2.4-1+b1) ...
Remove stale byte-compiled files...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 27, in <module>
import optparse
File "/usr/lib/python2.7/optparse.py", line 1557
print(self.get_usage(), file=file)
^
SyntaxError: invalid syntax
dpkg: error processing package python-dbus (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up python-xdg (0.25-4) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 27, in <module>
import optparse
File "/usr/lib/python2.7/optparse.py", line 1557
print(self.get_usage(), file=file)
^
SyntaxError: invalid syntax
dpkg: error processing package python-xdg (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of python-secretstorage:
python-secretstorage depends on python-dbus; however:
Package python-dbus is not configured yet.
dpkg: error processing package python-secretstorage (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-docutils:
python-docutils depends on python-roman; however:
Package python-roman is not configured yet.
dpkg: error processing package python-docutils (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-keyring:
python-keyring depends on python-dbus; however:
Package python-dbus is not configured yet.
python-keyring depends on python-secretstorage; however:
Package python-secretstorage is not configured yet.
dpkg: error processing package python-keyring (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-gobject:
python-gobject depends on python-gi (>= 3.22.0-2); however:
Package python-gi is not configured yet.
dpkg: error processing package python-gobject (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of python-poppler:
python-poppler depends on python-gobject (>= 2.10.1); however:
Package python-gobject is not configured yet.
dpkg: error processing package python-poppler (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
python-crypto
python-wheel
python-roman
python-pypdf2
python-keyrings.alt
python-gi
python-epydoc
pdfshuffler
python-dbus
python-xdg
python-secretstorage
python-docutils
python-keyring
python-gobject
python-poppler
E: Sub-process /usr/bin/dpkg returned an error code (1)
sudo apt-get install
当我尝试使用任何 python-PACKAGE时,它会得到类似的结果。我还尝试编辑 /var/lib/dpkg/status 文件,删除未正确安装或配置的 python 软件包的条目,但它没有帮助(尝试重新安装或删除这些软件包时再次出现相同的问题)。
任何想法?
谢谢你!
(系统:Debian Stretch w/KDE Plasma。I7 8500U 16Gb)
下列的菲利普·布兰德伯格的评论,我在 optparse.py 中查找了错误:
eric@debian:~$ dpkg -S /usr/lib/python2.7/optparse.py
libpython2.7-minimal:amd64: /usr/lib/python2.7/optparse.py
eric@debian:~$ dpkg -V libpython2.7-minimal
??5?????? /usr/lib/python2.7/optparse.py
eric@debian:~$ ls -l /usr/lib/python2.7/optparse.py
-rw-r--r-- 1 eric eric 60337 Mar 20 00:01 /usr/lib/python2.7/optparse.py
eric@debian:~$ readlink -f /usr/lib/python2.7/optparse.py
/usr/lib/python2.7/optparse.py
是不是说明md5sum验证失败了?
答案1
所以看起来optparse.py
你的 Python 2.7 安装中的文件已损坏。更具体地说,它似乎已被optparse.py
Python 3 的副本覆盖和替换。
的输出dpkg -V
显示了许多字段,检查所有者、组、模式等。5
输出中的 表示系统中文件的 MD5 校验和与包清单中的不匹配。 (也就是说,安装包后内容被修改了。)
不太确定你如何找出可能导致这种情况的原因...如果你以 root 身份安装了 Python 模块,使用操作系统包发行版以外的其他东西,这可以解释它...也许如果你使用安装了某些东西pip
?虽然pip
通常擅长将 Python 2 和 Python 3 模块分开...另外,我不明白为什么它会optparse.py
特别涉及...
无论如何,要解决此问题,您可以要求 apt-get 重新安装该软件包,这应该可以解决损坏问题:
$ sudo apt-get install --reinstall libpython2.7-minimal