![python 问题报告 python-apport apport break apt-get](https://linux22.com/image/1079377/python%20%E9%97%AE%E9%A2%98%E6%8A%A5%E5%91%8A%20python-apport%20apport%20break%20apt-get.png)
apt-get
自从软件包以来,我无法再使用 来安装或升级软件包python-problem-report
,python-apport
这apport
似乎会导致一些问题。apt-get
我尝试过的任何命令都会导致以下错误消息:
Preparing to replace python-problem-report 2.0.1-0ubuntu15.1 (using .../python-problem-report_2.0.1-0ubuntu15.1_all.deb) ...
File "/usr/bin/pyclean", line 64
except (IOError, OSError), e:
^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
File "/usr/bin/pyclean", line 64
except (IOError, OSError), e:
^
SyntaxError: invalid syntax
dpkg: error processing /var/cache/apt/archives/python-problem-report_2.0.1-0ubuntu15.1_all.deb (--unpack):
subprocess new pre-removal script returned error exit status 1
Traceback (most recent call last):
File "/usr/bin/pycompile", line 36, 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 while cleaning up:
subprocess installed post-installation script returned error exit status 1
Preparing to replace python-apport 2.0.1-0ubuntu15.1 (using .../python-apport_2.0.1-0ubuntu15.1_all.deb) ...
File "/usr/bin/pyclean", line 64
except (IOError, OSError), e:
^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
File "/usr/bin/pyclean", line 64
except (IOError, OSError), e:
^
SyntaxError: invalid syntax
dpkg: error processing /var/cache/apt/archives/python-apport_2.0.1-0ubuntu15.1_all.deb (--unpack):
subprocess new pre-removal script returned error exit status 1
Traceback (most recent call last):
File "/usr/bin/pycompile", line 36, 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 while cleaning up:
subprocess installed post-installation script returned error exit status 1
Preparing to replace apport 2.0.1-0ubuntu15.1 (using .../apport_2.0.1-0ubuntu15.1_all.deb) ...
apport stop/waiting
File "/usr/bin/pyclean", line 64
except (IOError, OSError), e:
^
SyntaxError: invalid syntax
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg - trying script from the new package instead ...
File "/usr/bin/pyclean", line 64
except (IOError, OSError), e:
^
SyntaxError: invalid syntax
dpkg: error processing /var/cache/apt/archives/apport_2.0.1-0ubuntu15.1_all.deb (--unpack):
subprocess new pre-removal script returned error exit status 1
apport start/running
Traceback (most recent call last):
File "/usr/bin/pycompile", line 36, 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 while cleaning up:
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/python-problem-report_2.0.1-0ubuntu15.1_all.deb
/var/cache/apt/archives/python-apport_2.0.1-0ubuntu15.1_all.deb
/var/cache/apt/archives/apport_2.0.1-0ubuntu15.1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
即使我尝试安装与这 3 个麻烦软件包无关的软件包,也会发生这种情况。我还为muon
这 3 个软件包选择了“锁定在当前版本”,但仍然会出现相同的错误。
任何帮助将不胜感激。
答案1
我找到了问题所在。我手动安装了较新版本的python
(版本 3.2,但通过软件包安装的版本是 2.7),然后我重定向/usr/bin/python
到python3.2
。显然在 3.2 中使用到的一些语法/usr/bin/pyclean
不再有效。恢复 到 的原始链接/usr/bin/python
解决/usr/bin/python2
了问题。现在脚本可以毫无问题地运行了。
我希望这对某人有帮助......
答案2
我也遇到了同样的问题。更简洁的解决方案是使用:
sudo update-alternatives --config python
There are 3 choices for the alternative python (providing /usr/bin/python).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/python3 30 auto mode
1 /usr/bin/python2.6 20 manual mode
2 /usr/bin/python2.7 10 manual mode
3 /usr/bin/python3 30 manual mode
Press enter to keep the current choice[*], or type selection number:
然后选择您要使用的版本。为了解决这个问题,我切换回 2.7,然后在使用 apt 清除所有问题后重置为 3。