记录一下卸载wsl原装python带来的问题

问题描述

前几天想用python3,就把wsl(ubuntu)中的python给删了,结果导致apt安装任何软件时都出现下面的错误:

After this operation, 0 B of additional disk space will be used.
Setting up python-wheel (0.29.0-1) ...
/var/lib/dpkg/info/python-wheel.postinst: 6: /var/lib/dpkg/info/python-wheel.postinst: pycompile: not found
dpkg: error processing package python-wheel (--configure):
 installed python-wheel package post-installation script subprocess returned error exit status 127
Setting up python-pkg-resources (20.7.0-1) ...
/var/lib/dpkg/info/python-pkg-resources.postinst: 6: /var/lib/dpkg/info/python-pkg-resources.postinst: pycompile: not
found
dpkg: error processing package python-pkg-resources (--configure):
 installed python-pkg-resources package post-installation script subprocess returned error exit status 127
Setting up python-pip (8.1.1-2ubuntu0.4) ...
/var/lib/dpkg/info/python-pip.postinst: 6: /var/lib/dpkg/info/python-pip.postinst: pycompile: not found
dpkg: error processing package python-pip (--configure):
 installed python-pip package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of python-setuptools:
 python-setuptools depends on python-pkg-resources (= 20.7.0-1); however:
  Package python-pkg-resources is not configured yet.

dpkg: error processing package python-setuptools (--configure):
 dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 python-wheel
 python-pkg-resources
 python-pip
 python-setuptools
E: Sub-process /usr/bin/dpkg returned an error code (1)

解决办法

在网上查找解决办法,也尝试了很多网上说的方法,但是都没有作用,最后找到这样一个,有效:

[root@wgq /mnt/d/ubuntu]# mv /var/lib/dpkg/info/ /var/lib/dpkg/info_old/
[root@wgq /mnt/d/ubuntu]# mkdir /var/lib/dpkg/info/
[root@wgq /mnt/d/ubuntu]# apt-get update
0% [Waiting for headers]

Hit:1 http://mirrors.ustc.edu.cn/ubuntu xenial InRelease
Hit:2 http://mirrors.ustc.edu.cn/ubuntu xenial-security InRelease
Hit:3 http://mirrors.ustc.edu.cn/ubuntu xenial-updates InRelease
Hit:4 http://mirrors.ustc.edu.cn/ubuntu xenial-backports InRelease
Hit:5 http://mirrors.ustc.edu.cn/ubuntu xenial-proposed InRelease
Reading package lists... Done
[root@wgq /mnt/d/ubuntu]# apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libfreetype6 libsigsegv2 pastebinit python3-newt run-one
Use 'apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.
4 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up python-wheel (0.29.0-1) ...
Setting up python-pkg-resources (20.7.0-1) ...
Setting up python-pip (8.1.1-2ubuntu0.4) ...
Setting up python-setuptools (20.7.0-1) ...
W: APT had planned for dpkg to do more than it reported back (0 vs 13).
   Affected packages: python-pip:amd64 python-pkg-resources:amd64 python-setuptools:amd64 python-wheel:amd64

总结

wsl就不要动它的python!!!

后记

整个把wsl卸载了重新安装了一遍!

评论