Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting Ansible bad python interpreter error?

Tags:

python

ansible

I installed ansible on MAC High Sierra 10.13.3 and when I am trying to run

"ansible --version" I am receiving following error

-bash: /usr/local/bin/ansible: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory

Please let me know if you have ran into same issue or have solution.

like image 824
Ravi Patel Avatar asked Oct 25 '25 23:10

Ravi Patel


1 Answers

/usr/local/bin/ansible has PATH "/usr/local/opt/python/bin/python2.7" on the first line. and in /usr/local/opt/python/bin/ directory I had python3.6 instead of python2.7.

So I changed PATH on file vi /usr/local/bin/ansible

from #!/usr/local/opt/python/bin/python2.7 to #!/usr/local/opt/python/bin/python3.6 and that fixed the issue

Verification :

$ ansible --version
  ansible 2.5.0
  config file = None
  configured module search path = ['/Users/<username>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/<username>/Library/Python/3.6/lib/python/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.6.4 (default, Mar  1 2018, 18:36:50) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]


$ ansible localhost -m ping

  localhost | SUCCESS => {
    "changed": false,
    "ping": "pong"
  }


$ ansible localhost -m setup -a 'filter=ansible_distribution' 
  localhost | SUCCESS => {
    "ansible_facts": {
        "ansible_distribution": "MacOSX"
    },
    "changed": false
  }
like image 187
Ravi Patel Avatar answered Oct 27 '25 12:10

Ravi Patel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!