I've installed ansible on my Mac using pip as advised by ansible's documentation: https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-on-macos
However when I try to run ansible I get the following:
zsh: command not found: ansible
I've never had this problem when installing ansible before.
pip-installing again tells me it's already installed under site packages:
Requirement already satisfied: ansible in ./Library/Python/3.8/lib/python/site-packages (2.9.11)
And my python installation in ~/.zshrc points to:
# Add user python 3.7 to path
export PATH="/usr/local/opt/python/libexec/bin:$PATH"
Might be obvious to some but I can't figure out why this simple installation isn't working..
For Modern macos/OSX, you need to find your ~/Library/Python/$version/bin directory and add it to your $PATH. This will help you locate the one where ansible got installed.
By default, Ansible's configuration file location is /etc/ansible/ansible.
After installing ansible with python3 -m pip install --user ansible
, I searched for the ansible binary and found it to be downloaded into ~/Library/Python/3.8/bin
. The simplest way is to figure this out is:
$ cd ~
$ find . | grep ansible
<lines omitted>
./Library/Python/3.8/bin/ansible
<lines omitted>
From there, its pretty easy, just update your .bash_profile or .zshrc with
export PATH="/path/to/Library/Python/3.8/bin:$PATH"
And you should be good to go:
$ source ~/.zshrc
$ ansible --version
ansible 2.10.8
config file = None
configured module search path = ['/Users/dbove/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
brew install ansible
brew link ansible
Below commands worked for me:
Uninstall ansible
sudo pip uninstall ansible
Then install by using (Note: -H flag is important here which sets HOME variable to target user's home dir)
sudo -H pip3 install ansible
Check the version by using
ansible --version
Uninstall ansible sudo pip uninstall ansible
.
Then install by using pip3 sudo pip3 install ansible
.
Check the version by using ansible --version
.
Note: Make sure you have pip3 installed, In case you don't have then install by usingansible 2.10.3
brew install python3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With