修复 Python 依赖混乱

修复 Python 依赖混乱

我在 Raspberry Pi 上安装了一些 Python 软件,一部分用 pip,另一部分用 apt-get。所以我现在的情况是,有一些等待安装的软件包假设是 Python 3.5,而其他的假设是 Python 2.7,不知何故这导致了某种死锁,我找不到出路。

现在,无论我使用 apt-get 接触什么软件,都会出现以下错误:

Setting up python-crypto (2.6.1-7) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 35, in <module>
`enter code here`    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-crypto (--configure):
 subprocess installed post-installation script returned error exit status 1

我怎样才能解决这个问题?

apt-get clean、autoclean、purge 不执行任何操作,因为所述软件不存在于 armhf 中(这就是我尝试使用 pip 安装它的原因)。 pip uninstall不执行任何操作,因为它不知何故认为库根本没有安装。

pi@raspberrypi ~> sudo apt-get install python-wheel
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-wheel is already the newest version (0.29.0-2).
python-wheel set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
7 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up python-crypto (2.6.1-7) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 35, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
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 35, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-wheel (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up python-gi (3.22.0-2) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 35, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-gi (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up python-dbus (1.2.4-1) ...
Remove stale byte-compiled files...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 35, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-dbus (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up python-pip (9.0.1-2+rpt2) ...
Traceback (most recent call last):
  File "/usr/bin/pycompile", line 35, in <module>
    from debpython.version import SUPPORTED, debsorted, vrepr, \
  File "/usr/share/python/debpython/version.py", line 24, in <module>
    from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-pip (--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-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
Errors were encountered while processing:
 python-crypto
 python-wheel
 python-gi
 python-dbus
 python-pip
 python-secretstorage
 python-keyring
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

我不得不将系统 python 链接回 python2.7。显然我将其更改为 python3.5,这导致了此错误。

相关内容