ubuntu 损坏 python 安装错误
ubuntu broken python installation by mistake
我已经尝试更新 Python 但我不知道版本隔离而是删除版本,所以,我删除了 [=] 中的所有 Python 版本32=] 16.04 VPS。现在我无法通过 apt-get 安装任何东西。
:
root@vps15:/# apt-get install --reinstall python3.5
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
dh-python : Depends: python3:any (>= 3.3.2-2~)
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
我尝试手动安装源代码 Python 2.7 到 /usr/lib,现在可以使用了,但现在的问题是这个依赖项:“dh-python”。
# apt-get install python3.5-minimal
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3.5-minimal is already the newest version (3.5.2-2ubuntu0~16.04.5).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
python3.5-minimal : Depends: libpython3.5-minimal (= 3.5.2-2ubuntu0~16.04.5) but it is not installable
Recommends: python3.5 but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
我已经尝试了列出的所有方法,但无法修复依赖项。
在尝试修复之前,问题是 Python2.7 而不是 python3,现在通过手动安装 python3 没有解决问题。
经过更多研究,我创建了一个与 Debian 相关的 post。处理 Ubuntu 16.04 的一些修改,尝试了本指南并现在可以正常工作:
步骤 1.
cd /tmp
apt-get download libpython3.5-minimal
apt-get download python3.5-minimal
apt-get download python3-minimal
apt-get download libpython3.5-stdlib
apt-get download python3.5
第 2 步
rm -rf /usr/local/lib/python3.5*
rm -rf /usr/local/bin/python3.5*
update-alternatives --remove python3 /usr/local/bin/python3.5
hash -r # removes cached python3 binary path
步骤 3.
cd /tmp
dpkg-deb -x libpython3.5-minimal_3.5.2-2ubuntu0~16.04.13_amd64.deb missing
dpkg-deb -x libpython3.5-stdlib_3.5.2-2ubuntu0~16.04.13_amd64.deb missing
dpkg-deb -x python3.5-minimal_3.5.2-2ubuntu0~16.04.13_amd64.deb missing
dpkg-deb -x python3.5_3.5.2-2ubuntu0~16.04.13_amd64.deb missing
dpkg-deb -x python3-minimal_3.5.1-3_amd64.deb missing
第 4 步
cd /tmp/missing
ls -lR /tmp/missing # if you are curious about overwriting your HD
sudo cp -rpfv /tmp/missing/* /
第 5 步
python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
导入并测试新版本:
>>> import sys
>>> print(sys.version_info)
sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)
>>>
>>> quit()
第 6 步
rm -rf /tmp/missing
第 7 步
dpkg -s -a python3.5 | grep reinstreq
# Any listing also needs to be reinstalled along with python3
apt-get install --reinstall python3
第 8 步
apt-get autoclean
apt-get autoremove
# (see the packages that will autoremove, you need to reinstall it again after: apt-get install --fix-broken --reinstall <<packages>>)
第 9 步
尝试安装常用道具
sudo apt install software-properties-common
如果成功,则安装完成。
我已经在 Ubuntu 16.04 上尝试过此操作,安装 Python2.7 可以正常工作,但不能安装 Python3,或 Python3.5。我最初安装的是 Python3.5,这就是为什么尝试安装该版本而不是最新版本的原因。
我已经尝试更新 Python 但我不知道版本隔离而是删除版本,所以,我删除了 [=] 中的所有 Python 版本32=] 16.04 VPS。现在我无法通过 apt-get 安装任何东西。
:
root@vps15:/# apt-get install --reinstall python3.5
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
dh-python : Depends: python3:any (>= 3.3.2-2~)
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
我尝试手动安装源代码 Python 2.7 到 /usr/lib,现在可以使用了,但现在的问题是这个依赖项:“dh-python”。
# apt-get install python3.5-minimal
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3.5-minimal is already the newest version (3.5.2-2ubuntu0~16.04.5).
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
python3.5-minimal : Depends: libpython3.5-minimal (= 3.5.2-2ubuntu0~16.04.5) but it is not installable
Recommends: python3.5 but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
我已经尝试了列出的所有方法,但无法修复依赖项。
在尝试修复之前,问题是 Python2.7 而不是 python3,现在通过手动安装 python3 没有解决问题。
经过更多研究,我创建了一个与 Debian 相关的 post。处理 Ubuntu 16.04 的一些修改,尝试了本指南并现在可以正常工作:
步骤 1.
cd /tmp
apt-get download libpython3.5-minimal
apt-get download python3.5-minimal
apt-get download python3-minimal
apt-get download libpython3.5-stdlib
apt-get download python3.5
第 2 步
rm -rf /usr/local/lib/python3.5*
rm -rf /usr/local/bin/python3.5*
update-alternatives --remove python3 /usr/local/bin/python3.5
hash -r # removes cached python3 binary path
步骤 3.
cd /tmp
dpkg-deb -x libpython3.5-minimal_3.5.2-2ubuntu0~16.04.13_amd64.deb missing
dpkg-deb -x libpython3.5-stdlib_3.5.2-2ubuntu0~16.04.13_amd64.deb missing
dpkg-deb -x python3.5-minimal_3.5.2-2ubuntu0~16.04.13_amd64.deb missing
dpkg-deb -x python3.5_3.5.2-2ubuntu0~16.04.13_amd64.deb missing
dpkg-deb -x python3-minimal_3.5.1-3_amd64.deb missing
第 4 步
cd /tmp/missing
ls -lR /tmp/missing # if you are curious about overwriting your HD
sudo cp -rpfv /tmp/missing/* /
第 5 步
python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
导入并测试新版本:
>>> import sys
>>> print(sys.version_info)
sys.version_info(major=3, minor=7, micro=3, releaselevel='final', serial=0)
>>>
>>> quit()
第 6 步
rm -rf /tmp/missing
第 7 步
dpkg -s -a python3.5 | grep reinstreq
# Any listing also needs to be reinstalled along with python3
apt-get install --reinstall python3
第 8 步
apt-get autoclean
apt-get autoremove
# (see the packages that will autoremove, you need to reinstall it again after: apt-get install --fix-broken --reinstall <<packages>>)
第 9 步
尝试安装常用道具
sudo apt install software-properties-common
如果成功,则安装完成。
我已经在 Ubuntu 16.04 上尝试过此操作,安装 Python2.7 可以正常工作,但不能安装 Python3,或 Python3.5。我最初安装的是 Python3.5,这就是为什么尝试安装该版本而不是最新版本的原因。