Why can't I find ansible when I install it using setup.py?

When you invoke ansible from the shell, bash will search in your $PATH for a file named ansible that is executable. This may not be the only issue, but this is the immediate cause for the error you're seeing. The .egg file itself is not an executable, it's just a file used for distributing the code.

If ansible has been installed correctly, you should be able to find it by using locate or the OSX Finder GUI. The name should match exactly, with no file extensions. You will probably also find ansible-connection, ansible-console, etc. in the same place where you find the ansible executable. If you find it, great! Test it out and add that directory to your $PATH in a terminal like so:

export PATH=$PATH:/path/to/ansible

Where /path/to/ansible is the directory where you found the executables. This change to the $PATH variable is temporary, and will go away when you close your shell. If you can now run ansible from bash, then you can make the change permanent by adding that export to the end of your $HOME/.bash_profile file, or by adding a rule in /etc/paths.d (recommended by Apple). See more on how exactly to do those here if you are unfamiliar with them.

Now, if that's not the problem and you can't find the ansible executable, then the installation itself is your problem. You might also try using a virtual environment (if you have it installed) to make sure that the version you're pulling from github isn't broken:

git clone https://github.com/ansible/ansible.git
cd ansible
virtualenv venv
source venv/bin/activate
pip install .
which ansible

As of this writing, the above gives me a working ansible install.


Find where ansible reside on your Mac. Most times its /Users/<yourusername>/Library/Python/3.7/bin or /Users/<yourusername>/Library/Python/2.7/bin. Then ...

export PATH=$PATH:/Users/<yourusername>/Library/Python/3.7/bin

You can store this in your .bashrc file.


Well, I think you just need to create a soft link

ln -s /Users/${yourname}/Library/Python/${python version}/bin/ansible /usr/local/bin/ansible