how could I use python 3 for ansible command

11 views
Skip to first unread message

Jason Yu

unread,
Mar 1, 2019, 8:36:46 PM3/1/19
to Ansible Project
I have two versions of python installed. If I don't run the scl command, I will use python  2.7, but when I use scl command, it swith to use python 3. What is the difference between these two methods?

When I try to see which verion of python ansible uses, it says version 2.7. how could I make anislbe use version 3. 

[root@g0dvlnxjyu01 ~]# python -V
Python 2.7.5

[root@g0dvlnxjyu01 ~]# scl enable rh-python36 bash
[root@g0dvlnxjyu01 ~]# python -V
Python 3.6.3
[root@g0dvlnxjyu01 ~]# ansible --version | grep "python version"
  python version = 2.7.5 (default, Sep 12 2018, 05:31:16) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
[root@g0dvlnxjyu01 ~]# which version
/usr/bin/which: no version in (/opt/rh/rh-python36/root/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/omi/bin:/root/.local/bin:/root/Repo/DevOps/AWS/terra-test:/root)
[root@g0dvlnxjyu01 ~]# which python
/opt/rh/rh-python36/root/usr/bin/python
[root@g0dvlnxjyu01 ~]#

Reply all
Reply to author
Forward
0 new messages