不小心删除了/usr/bin/python3.5,无法重新安装

Mit*_*ril 4 uninstall python python3 software-installation reinstall

操作系统:Ubuntu 14.04

我看到了一个类似的问题,但那里提到的方法都不起作用。

我通过运行安装了 python 3.5:

apt-get install -y software-properties-common && \
add-apt-repository ppa:fkrull/deadsnakes && \
apt-get update
apt-get install -y python3.5 python3.5-dev
Run Code Online (Sandbox Code Playgroud)

我运行出错了ln -sf /usr/bin/python /usr/bin/python3.5,所以符号链接python3.5变成了python2.7.

我试过了:

1.

rm -f /etc/apt/sources.list.d/*
dpkg --configure -a
add-apt-repository ppa:fkrull/deadsnakes
apt-get update
apt-get install --reinstall python3.5 python3.5-dev
Run Code Online (Sandbox Code Playgroud)

2.

apt-get remove --purge python3.5 python3.5-dev
apt-get install python3.5 python3.5-dev
Run Code Online (Sandbox Code Playgroud)

在这两种情况下,我都得到了类似的信息:

/var/lib/dpkg/info/python3.5.postinst: 9: /var/lib/dpkg/info/python3.5.postinst: python3.5: not found
dpkg: error processing package python3.5 (--configure):
 subprocess installed post-installation script returned error exit status 127
dpkg: dependency problems prevent configuration of python3.5-dev:
 python3.5-dev depends on python3.5 (= 3.5.2-1~trusty1); however:
  Package python3.5 is not configured yet.

dpkg: error processing package python3.5-dev (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 python3.5
 python3.5-dev
E: Sub-process /usr/bin/dpkg returned an error code (1)
Run Code Online (Sandbox Code Playgroud)

Mit*_*ril 10

我修好了它。

查找所有依赖项:

dpkg -l | grep python3.5
Run Code Online (Sandbox Code Playgroud)

删除所有这些:

apt-get --purge remove libpython3.5 libpython3.5-dev libpython3.5-minimal libpython3.5-stdlib python3.5 python3.5-dev python3.5-minimal
Run Code Online (Sandbox Code Playgroud)

重新安装

apt-get install python3.5-dev
Run Code Online (Sandbox Code Playgroud)