如何在centOS 8上安装不同版本的python?
How to install different versions of python on centOS 8?
我在 CentOS Linux 8.3 版
上安装了 python3.6
[fnord@fnord fnord]$ ls -ls /usr/bin/python*
0 lrwxrwxrwx 1 root root 9 Aug 31 2020 /usr/bin/python2 -> python2.7
12 -rwxr-xr-x 1 root root 8224 Aug 31 2020 /usr/bin/python2.7
0 lrwxrwxrwx. 1 root root 25 Jun 24 2020 /usr/bin/python3 -> /etc/alternatives/python3
0 lrwxrwxrwx 1 root root 31 Nov 4 2020 /usr/bin/python3.6 -> /usr/libexec/platform-python3.6
0 lrwxrwxrwx 1 root root 17 Nov 4 2020 /usr/bin/python3.6-config -> python3.6m-config
0 lrwxrwxrwx 1 root root 32 Nov 4 2020 /usr/bin/python3.6m -> /usr/libexec/platform-python3.6m
0 lrwxrwxrwx 1 root root 39 Nov 4 2020 /usr/bin/python3.6m-config -> /usr/libexec/platform-python3.6m-config
0 lrwxrwxrwx 1 root root 46 Nov 4 2020 /usr/bin/python3.6m-x86_64-config -> /usr/libexec/platform-python3.6m-x86_64-config
0 lrwxrwxrwx 1 root root 32 Mar 16 2021 /usr/bin/python3-config -> /etc/alternatives/python3-config
[fnord@fnord fnord]$ python3 --version
Python 3.6.8
[fnord@fnord fnord]$cat /etc/centos-release
CentOS Linux release 8.3.2011
如何在同一系统上安装 python3.7, python3.8,...?
使用 dnf
例如
dnf install python38
然后您可以使用 venv 来管理您在特定项目中使用的 python 版本
我在 CentOS Linux 8.3 版
上安装了 python3.6[fnord@fnord fnord]$ ls -ls /usr/bin/python*
0 lrwxrwxrwx 1 root root 9 Aug 31 2020 /usr/bin/python2 -> python2.7
12 -rwxr-xr-x 1 root root 8224 Aug 31 2020 /usr/bin/python2.7
0 lrwxrwxrwx. 1 root root 25 Jun 24 2020 /usr/bin/python3 -> /etc/alternatives/python3
0 lrwxrwxrwx 1 root root 31 Nov 4 2020 /usr/bin/python3.6 -> /usr/libexec/platform-python3.6
0 lrwxrwxrwx 1 root root 17 Nov 4 2020 /usr/bin/python3.6-config -> python3.6m-config
0 lrwxrwxrwx 1 root root 32 Nov 4 2020 /usr/bin/python3.6m -> /usr/libexec/platform-python3.6m
0 lrwxrwxrwx 1 root root 39 Nov 4 2020 /usr/bin/python3.6m-config -> /usr/libexec/platform-python3.6m-config
0 lrwxrwxrwx 1 root root 46 Nov 4 2020 /usr/bin/python3.6m-x86_64-config -> /usr/libexec/platform-python3.6m-x86_64-config
0 lrwxrwxrwx 1 root root 32 Mar 16 2021 /usr/bin/python3-config -> /etc/alternatives/python3-config
[fnord@fnord fnord]$ python3 --version
Python 3.6.8
[fnord@fnord fnord]$cat /etc/centos-release
CentOS Linux release 8.3.2011
如何在同一系统上安装 python3.7, python3.8,...?
使用 dnf
例如
dnf install python38
然后您可以使用 venv 来管理您在特定项目中使用的 python 版本