Python in RHEL 8

To install Python2 or 3

yum install python3
 or
yum install python2

Why not just “Python”
[root@ip-172-31-41-9 init.d]# python
-bash: python: command not found
[root@ip-172-31-41-9 init.d]# 

That’s why you can use the alternatives mechanism to enable the unversioned python command system-wide

alternatives --set python /usr/bin/python3
[root@ip-172-31-41-9 init.d]# alternatives --set python /usr/bin/python3
[root@ip-172-31-41-9 init.d]# python
Python 3.6.8 (default, Aug 18 2020, 08:33:21) 
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Note that this works only for the python command itself. Packages and other commands don’t have configurable unversioned variants. Even if you configure python, the commands yum install python-requests or pip won’t work.

Always use the explicit version in these cases. Better yet, don’t rely on the wrapper scripts for pip, venv and other Python modules that you call from the command line. Instead use python3 -m pip, python3 -m venv, python2 -m virtualenv.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值