python 和包管理器坏了

python 和包管理器坏了

将 Ubuntu 从 升级到 后15.0416.04pythonpackage manager损坏了。

运行时apt-get update我收到消息use apt-get -f install,但运行此命令时出现以下错误:

Get:1 http://at.archive.ubuntu.com/ubuntu xenial/main amd64 python amd64 2.7.11-1 [137 kB]
Fetched 137 kB in 0s (1.700 kB/s)
Setting up python-minimal (2.7.11-1) ...
Traceback (most recent call last):
   File "/usr/local/lib/python2.7/runpy.py", line 162, in _run_module_as_main
"  __main__", fname, loader, pkg_name)
File "/usr/local/lib/python2.7/runpy.py", line 72, in _run_code
 exec code in run_globals
File "/usr/local/lib/python2.7/compileall.py", line 16, in <module>
 import struct
File "/usr/local/lib/python2.7/struct.py", line 1, in <module>
 from _struct import *
ImportError: No module named _struct 
dpkg: error processing package python-minimal (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
  python-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)

我也尝试了其他帖子中提出的解决方案:

sudo dpkg-reconfigure python-minimal
/usr/sbin/dpkg-reconfigure: python-minimal is broken or not fully installed

sudo dpkg --configure -a
Setting up python-minimal (2.7.11-1) ...
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/runpy.py", line 162, in _run_module_as_main
  "__main__", fname, loader, pkg_name)
  File "/usr/local/lib/python2.7/runpy.py", line 72, in _run_code
   exec code in run_globals
  File "/usr/local/lib/python2.7/compileall.py", line 16, in <module>
   import struct
  File "/usr/local/lib/python2.7/struct.py", line 1, in <module>
   from _struct import *
  ImportError: No module named _struct
  dpkg: error processing package python-minimal (--configure):
  subprocess installed post-installation script returned error exit status 1
  Errors were encountered while processing:
    python-minimal

reinstall python-minimal没有用。

另外,当我尝试运行时apt-get remove|autoremove,我得到了同样的结果python error

更新 1

我刚刚尝试过:

apt-get download python-minimal
sudo dpkg --install ./python-minimal_2.7.11-1_amd64.deb

但我仍然遇到同样的错误

更新2

我通过以下步骤删除损坏的python包裹:

apt-get download synaptic
sudo dpkg --install ./synaptic...

然后我使用 删除了包synaptic,但问题是,现在删除它们后,每次我想要安装某些东西时,包管理器都会自动尝试安装python2.7-11python-minimal-2.7-11,但没有成功,我再次收到错误。

答案1

在升级到之前Ubuntu 16.04,我已经python2.7.5安装了,并且我假设在升级过程中,Ubuntu尝试python从升级2.7.52.7.11,但失败了,所以我最终python2.7.5在笔记本电脑上仍然保留着文件并python2.7.11部分安装。

我通过这样做解决了我的错误:

  • 删除了部分安装的,如我的问题python2.7.11中所述UPDATE2
  • 删除了文件夹python2.7.5

    sudo rm -rf /usr/lib/python2.7/
    
  • 重新安装python2.7->python2.7.11并且其依赖项已正确安装
  • 完成了!现在一切正常!

相关内容