安装 Ubuntu 20.04 后,我可以删除旧版本的 Python 吗?

安装 Ubuntu 20.04 后,我可以删除旧版本的 Python 吗?

我曾经使用过 Ubuntu 16.04,有一次我错误地尝试删除 Python 3.5.2,但是这造成了很大的危害,我不得不重新安装很多东西。

现在,我已经升级到 20.04,其中默认的 Python 是 3.8.2。我可以毫无损害地删除 3.5.2 版本吗?

那么 2.7.18 版本呢 - 它仍然安装着 - 我可以删除它吗?

答案1

当然,Ubuntu 20.04 不需要您提到的旧版本的 Python,但您可能有自己的脚本,这些脚本可能“连接”了默认解释器(#!/usr/bin/python 等)。

答案2

除非您安装了 2.7 或 3.6,或者您安装的某个应用程序添加了它们,否则您不应该拥有它们。我保留了几个想要安装的应用程序,因此只有默认的 python。

fred@Z170N-focal:~$ ls -l /usr/bin/python*
lrwxrwxrwx 1 root root       9 Mar 13 08:20 /usr/bin/python3 -> python3.8
-rwxr-xr-x 1 root root 5457536 Apr 27 11:53 /usr/bin/python3.8
lrwxrwxrwx 1 root root      33 Apr 27 11:53 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config
lrwxrwxrwx 1 root root      16 Mar 13 08:20 /usr/bin/python3-config -> python3.8-config
-rwxr-xr-x 1 root root     384 Mar 27 22:39 /usr/bin/python3-futurize
-rwxr-xr-x 1 root root     388 Mar 27 22:39 /usr/bin/python3-pasteurize

答案3

这是我经常使用的 Ubuntu 20.04,它是直接安装的,而不是升级

ls -l /usr/bin/python*
lrwxrwxrwx 1 root root       9 Mar 13 08:31 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root 3694632 Apr  7 08:05 /usr/bin/python2.7
lrwxrwxrwx 1 root root      33 Apr  7 08:05 /usr/bin/python2.7-config -> x86_64-linux-gnu-python2.7-config
lrwxrwxrwx 1 root root      16 Mar 13 08:31 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root       9 Mar 13 08:20 /usr/bin/python3 -> python3.8
-rwxr-xr-x 1 root root 5457536 Apr 27 11:53 /usr/bin/python3.8
lrwxrwxrwx 1 root root      33 Apr 27 11:53 /usr/bin/python3.8-config -> x86_64-linux-gnu-python3.8-config
lrwxrwxrwx 1 root root      16 Mar 13 08:20 /usr/bin/python3-config -> python3.8-config
-rwxr-xr-x 1 root root     384 Mar 27 22:39 /usr/bin/python3-futurize
-rwxr-xr-x 1 root root     388 Mar 27 22:39 /usr/bin/python3-pasteurize

这显示了 2.7 版软件包

dpkg -l|grep  python2.7

清除我的 python2.7 软件包后 -> 重启 -> 一切正常,所以我想继续随意操作

请注意,手动安装的代码如果未使用 ubuntu 软件包安装但依赖 2.7,则将被孤立

答案4

Python 用于许多系统脚本。因此,我将保留所有 Python 3 模块不变。但是,Python 2 不再受支持。因此,您可以删除 Python2 - 但这会使你无法尝试测试一些你可能希望在将来使用的旧脚本...

当前 Ubuntu 20.04 上未安装 python2。(它们可能隐藏在 snap 中)

相关内容