0.首先删除/usr/bin/python3.10,会导致以下错误:
<1>.报错1:
ModuleNotFoundError: No module named ‘apt_pkg’
<2>.报错2:
bash: /usr/lib/command-not-found: /usr/bin/python3: 解释器错误: 没有那个文件或目录
<3>.报错3:
通过亲身操作,以下步骤可以将此两种问题解决,将机器救回来.
1.误删/usr/bin/python3.10如何救回来
<1>.下载python3.10.11源码
https://www.python.org/downloads
# ./configure
# make -j20
# make install
<2>.配置python3.10.11到系统文件
# sudo ln -s /usr/local/bin/python3.10.11 /usr/bin/python3
# sudo ln -s /usr/local/bin/python3.10.11 /usr/bin/python
<3>.设置python3.10.11优先级
python配置优先级用法
update-alternatives: --install needs <link> <name> <path> <priority>
//设置python3.10.11为第一优先级
# sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10.11 1
//设置python2.7为第二优先级
# sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python2.7 2
# sudo update-alternatives --config python3
查看python2.x优先级
# update-alternatives --display python
python - 自动模式
最佳链接版本为 /usr/bin/python2.7
链接目前指向 /usr/bin/python2.7
链接 python 指向 /usr/bin/python
/usr/bin/python2.7 - 优先级 1
查看python3.x优先级
# update-alternatives --display python3
<4>.重新安装python3和python3-apt
# sudo apt install --reinstall python3
# sudo apt install --reinstall python3-apt
这时候其实python3.10已经回来了.
<5>.设置/usr/bin/python3为第一优先级
# sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.10 1
# sudo update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python2.7 2
# sudo update-alternatives --config python3
2.建议一些危险的操作在docker下实验
可以搭建一个docker,在一些危险的操作,可以在docker运行.