合 CentOS8安装配置python
安装
CentOS 8 默认情况下不安装任何 版本的 Python
, 需要管理员自己进行安装,可以使用yum直接安装。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | [root@docker35 ~]# docker pull daocloud.io/library/centos:8.2.2004 8.2.2004: Pulling from library/centos 6910e5a164f7: Already exists Digest: sha256:fd84102fc72960dd1b8da0ee3b4c13e3b0c1d2a085de118bc4c97821cd986e02 Status: Downloaded newer image for daocloud.io/library/centos:8.2.2004 daocloud.io/library/centos:8.2.2004 [root@docker35 ~]# [root@docker35 ~]# docker run -d --name lhrcentos82 -h lhrcentos82 --privileged=true daocloud.io/library/centos:8.2.2004 /usr/sbin/init 7775303884b19485cfecc6d2e768dbb4b611d905e21bff969cb916812547a8e4 [root@docker35 ~]# docker exec -it lhrcentos82 bash [root@lhrcentos82 /]# cat /etc/redhat-release CentOS Linux release 8.2.2004 (Core) [root@lhrcentos82 ~]# dnf install python2 python3 -y 。。。 Dependencies resolved. ==================================== Package ==================================== Installing: python2 python36 Upgrading: platform-python-setuptools Installing dependencies: platform-python-pip python2-libs python2-pip-wheel python2-setuptools-wheel python3-pip python3-setuptools Installing weak dependencies: python2-pip python2-setuptools Enabling module streams: python27 python36 Transaction Summary ==================================== Install 10 Packages Upgrade 1 Package Total download size: 12 M 。。。 [root@lhrcentos82 ~]# python2 -V Python 2.7.18 [root@lhrcentos82 ~]# python3 -V Python 3.6.8 [root@lhrcentos82 ~]# python -V -bash: /usr/bin/python: No such file or directory [root@lhrcentos82 ~]# |
如果有多个版本,那么该如何设定 默认版本? 可以使用alternatives
控制默认版本: