我使用的是 Ubuntu 20.04,它附带了 Python 3.8。我想安装 Python 3.10 并删除 Python 3.8,因为我缺乏磁盘空间。我知道如何安装Python 3.10,但我担心一旦删除Python 3.8我就会破坏我的系统。
仅供参考,我计划使用这些命令来执行此操作(ofc 我以 root 用户身份运行所有内容):
add-apt-repository ppa:deadsnakes/ppa
apt install -y python3.10
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
update-alternatives --config python3 #then select python3.10
#found the above from https://www.itsupportwale.com/blog/how-to-upgrade-to-python-3-10-on-ubuntu-18-04-and-20-04-lts/
#my own code below
apt autoremove python3.8
Run Code Online (Sandbox Code Playgroud)
这是用 Python 3.10 替换 Python 3.8 的正确方法吗?谢谢 :)
PS我安装了一堆Python 3.8“插件”(抱歉,我喜欢这样称呼)python3.8-venv,如果它们不可用,我也想删除它们(我对此不确定,所以我没有将其包含在上面的代码中)。