安装 Python 软件包并运行 update-alternatives 后 APT 输出出现错误

安装 Python 软件包并运行 update-alternatives 后 APT 输出出现错误

我安装了 biopython 和 python 3.5,并将其设置为默认值

sudo apt-get install idle3
sudo apt-get install python3-numpy
sudo apt-get install python3-scipy
sudo apt-get install python3-biopython
update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2

一切都运行良好,但是现在 - 在成功安装其他东西后,我突然在安装字体管理器时遇到失败:

$ sudo apt-get install -f 
[sudo] password...: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python-biopython (1.66+dfsg-1build1) ...
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-biopython (--configure):
 subprocess installed post-installation script returned error exit status 1
Setting up python-libxml2 (2.9.3+dfsg1-1ubuntu0.1) ...
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-libxml2 (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 python-biopython
 python-libxml2
E: Sub-process /usr/bin/dpkg returned an error code (1)

现在,我知道该帖子Sub-process /usr/bin/dpkg returned an error code (1)已经发布了好几次,但每次的答案都是针对破损的包裹。

我尝试删除 python-biopython 和 libxml2,但由于这个包损坏,我现在无法安装或删除任何东西。Synaptic 都无法解决这个问题。

我宁愿跳过重新安装整个操作系统,那么有没有可以应用的解决方案?

非常感谢。

答案1

如果你的 python 默认版本为 python2,我认为你需要更改默认版本。请执行以下操作:

ls /usr/bin/python*

通过以下方式检查当前默认的 python:

python --version

然后检查 python 版本列表

 update-alternatives --list python

然后做:

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1

然后做:

 update-alternatives --list python

然后做:

sudo update-alternatives --config python

然后选择python版本2然后执行:

sudo apt-get install -f 

相关内容