4

I have been trying to install ansible from long time. It is giving success message when use below command.

Anupams-MacBook-Pro-2:bin anupamsri$ sudo pip install ansible  

The directory /Users/anupamsri/Library/Caches/pip/http or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

The directory /Users/anupamsri/Library/Caches/pip or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Collecting ansible Downloading ansible-2.4.3.0.tar.gz (6.5MB)
100% |████████████████████████████████| 6.5MB 200kB/s
Requirement already satisfied: jinja2 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ansible)
Requirement already satisfied: PyYAML in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ansible)
Requirement already satisfied: paramiko in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ansible)
Requirement already satisfied: cryptography in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ansible)
Requirement already satisfied: setuptools in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from ansible)
Requirement already satisfied: MarkupSafe>=0.23 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from jinja2->ansible)
Requirement already satisfied: pyasn1>=0.1.7 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from paramiko->ansible)
Requirement already satisfied: bcrypt>=3.1.3 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from paramiko->ansible)
Requirement already satisfied: pynacl>=1.0.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from paramiko->ansible)
Requirement already satisfied: six>=1.4.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography->ansible)
Requirement already satisfied: cffi>=1.7; platform_python_implementation != "PyPy" in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography->ansible)
Requirement already satisfied: enum34; python_version < "3" in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography->ansible)
Requirement already satisfied: asn1crypto>=0.21.0 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography->ansible)
Requirement already satisfied: idna>=2.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography->ansible)
Requirement already satisfied: ipaddress; python_version < "3" in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cryptography->ansible)
Requirement already satisfied: pycparser in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography->ansible)
Installing collected packages: ansible
Running setup.py install for ansible ... done
Successfully installed ansible-2.4.3.0

=========================================

But when I check ansible version after it its not found. I also used sudo -H option but same result.

I don’t see .ansible file anywhere in system as well. Please help how to install this because I have tried brew install as well but no luck.

Anupams-MacBook-Pro-2:bin anupamsri$ ansible --version -bash: ansible: command not found

2
  • same result after installing with brew install ansible Commented May 23, 2018 at 21:51
  • I am currently experiencing an issue with this as well. I tried to use pip to install ansible as yum was not letting me because of package dependencies that couldnt be pulled from the current repo. if you install it through pip it goes into the python 2.7 directory however it doesn't leave you with a /etc/ansible or ansible.cfg file. I'm working on a way to rectify this myself as I am hoping to start using ansible as well. Commented Aug 7, 2018 at 15:50

3 Answers 3

3

I had a similar issue on OS X, based on Harold's answer I checked the PATH variable and was able to solve it:

I found where pip installed ansible by initiating the uninstallation process with pip uninstall ansible, which printed the path to the ansible files that are to be removed. Instead of confirming with y, I aborted the uninstallation with n, exported the corresponding path to the PATH variable and then it worked.

Update: This approach will output various paths, the one you want to add to your PATH variable is the one to the bin folder holding the ansible commands (i.e. ansible, ansible-playbook etc.)

2
  • 1
    Path of which file did you add in your PATH variable. Uninstall command list so many files. I could not not understand which file to pickup Commented Nov 27, 2020 at 6:42
  • 1
    When you look at the paths you will see that most of them are pointing to the same binary folder which holds the basic ansible commands ansible, ansible-playbook etc. You should add the path to that bin folder to your PATH variable. I will update the answer to include this information.
    – nehtor.t
    Commented Nov 27, 2020 at 8:24
2

The most common cause of this, whether you're installing through pip or brew, is something not being in the PATH. The second answer here should offer some insight into this, if that is indeed the problem: https://stackoverflow.com/questions/35898734/pip-installs-packages-successfully-but-executables-not-found-from-command-line/35899029

1

For zsh, add below line in ~/.zshrc file.

export PATH="/Users/shantanu/Library/Python/3.9/bin:$PATH"

Source it.

source ~/.zshrc

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .