Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

zsh: command not found: ansible after pip installing

Tags:

macos

ansible

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..

like image 212
solarflare Avatar asked Jul 30 '20 16:07

solarflare


People also ask

Where does pip install ansible on Mac?

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.

Where is my ansible installed path?

By default, Ansible's configuration file location is /etc/ansible/ansible.


Video Answer


4 Answers

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']
like image 102
Domenic Bove Avatar answered Oct 16 '22 12:10

Domenic Bove


brew install ansible
brew link ansible

like image 42
NN88 Avatar answered Oct 16 '22 10:10

NN88


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

like image 5
Shivaraj Navalgund Avatar answered Oct 16 '22 12:10

Shivaraj Navalgund


Uninstall ansible sudo pip uninstall ansible.
Then install by using pip3 sudo pip3 install ansible.
Check the version by using ansible --version.

ansible 2.10.3

Note: Make sure you have pip3 installed, In case you don't have then install by using brew install python3
like image 2
Rajeev Kumar Avatar answered Oct 16 '22 12:10

Rajeev Kumar