我在Ubuntu 14.x.我正在尝试重新安装pip。包看起来处于不一致状态。 (可能是我之前做过的一些手动文件删除的结果。)重新安装不起作用,我不愿意通过apt-get强制删除包。怎么办?
如果我尝试删除pip包,我会收到此错误:
$ sudo apt-get remove python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
python-chardet-whl python-colorama python-colorama-whl python-distlib
python-distlib-whl python-html5lib python-html5lib-whl python-pip-whl
python-requests-whl python-setuptools-whl python-six-whl python-urllib3-whl
python-wheel
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
python-pip
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 477 kB disk space will be freed.
Do you want to continue? [Y/n] Y
dpkg: error processing package python-pip (--remove):
package is in a very bad inconsistent state; you should
reinstall it before attempting a removal
Errors were encountered while processing:
python-pip
E: Sub-process /usr/bin/dpkg returned an error code (1)
如果我然后尝试清理已安装的pip版本,我会收到此错误:
$ sudo apt-get install --reinstall python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/97.3 kB of archives.
After this operation, 0 B of additional disk space will be used.
Selecting previously unselected package python-pip.
(Reading database ... 71400 files and directories currently installed.)
Preparing to unpack .../python-pip_1.5.4-1ubuntu4_all.deb ...
File "/usr/bin/pyclean", line 63
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 63
except (IOError, OSError), e:
^
SyntaxError: invalid syntax
dpkg: error processing archive /var/cache/apt/archives/python-pip_1.5.4-1ubuntu4_all.deb (--unpack):
subprocess new pre-removal script returned error exit status 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 while cleaning up:
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/python-pip_1.5.4-1ubuntu4_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
谢谢!