python - ubuntu 错误安装 python 坏了

标签 python ubuntu sysadmin

我尝试更新 Python,但我不知道版本隔离,而是删除版本,因此,我删除了 Ubuntu 16.04 VPS 中的所有 Python 版本。现在我无法通过 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 相关的帖子。处理 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。
尝试安装通用 Prop 。
sudo apt install software-properties-common
如果它工作,现在安装完成。

我已经在 Ubuntu 16.04 上尝试过这个,安装了 Python2.7,但没有安装 Python3 或 Python3.5。我最初安装的是 Python3.5,这就是为什么尝试安装该版本而不是最新版本的原因。

关于python - ubuntu 错误安装 python 坏了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67621489/

相关文章:

distributed - 协调多个服务器之间的任务

linux - lvcreate 在物理卷上创建什么?会删除数据吗?

python - 如何在 Ubuntu 上使用 Python3.10?

shell - 从 OGG 文件中提取封面图像

python - 在 Ruby/Python 中可视化 x、y、z 坐标?

python - Celerybeat不运行周期性任务

apache - 如何使用apache重定向到docker容器

MySQL数据库神秘删除表

python - 如何更改子图中线条的颜色?

python - 使用正则表达式有一些困难