Installed ansible using pip on my macOS running Mojave (10.14.6)
pip install --user ansible
After running I got a successful installation
Successfully installed MarkupSafe-1.1.1 PyYAML-5.1.2 ansible-2.8.5 asn1crypto-1.0.1 cffi-1.12.3 cryptography-2.7 enum34-1.1.6 ipaddress-1.0.22 jinja2-2.10.3 pycparser-2.19
Running my first command
Macbook:~ t0o0tz$ ansible --version
-bash: ansible: command not found
Locate yielded no results. I ran an upgrade and received a bunch of:
Requirement already satisfied, skipping upgrade
During the upgrade I also got a location for ansible
ansible in /Users/t0o0tz/Library/Python/2.7/lib/python/site-packages (2.8.5)
But could not find ansible in 'site-packages'
site-packages contents below:
Extras.pth easy-install.pth vboxapi
README pip-19.2.3-py2.7.egg vboxapi-1.0-py2.7.egg-info
Am I missing something?
The executable file was located in $HOME/Library/Python/2.7/bin
./ansible --version
ansible 2.8.5
Thanks Matthew L Daniel!
Related
Installed Ansible on Mac using following command as documented here:
pip install --user ansible
However, can't find Ansible with version command:
~ $ ansible --version
-bash: ansible: command not found
any clues?
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.
try here:
/usr/local/lib/python3.9/site-packages/ansible
change python3.9 with your python version...
otherwise in terminal write:
where ansible
probably return a path similar to this:
/usr/local/bin/ansible
So due to some strict versioning requirements I need to downgrade my version of Ansible from 2.1.1.0 to 1.9.4
How can I do this (preferably with brew)?
If not with brew, then this may be an option. Otherwise I have heard that using virtual env may also be a good option so that I can easily run version 2.1.1.0 or 1.9.4 similar to the manner in which rbenv works.
I vote for virtualenv. But if you want to install ansible 1.9:
$> brew uninstall ansible
$> brew search ansible
ansible
ansible#1.9
ansible#2.0
...
$> brew install ansible#1.9
$> pip remove ansible
$> pip install ansible==1.9.4
$> ansible --version
ansible 1.9.4
configured module search path = None
If you use pip, you can use
pip install ansible==<version-number>
This will uninstall old version and install the new one.
This logs are from my local machine when I downgraded my version from 2.7.4 to 2.4.2
Installing collected packages: ansible
Found existing installation: ansible 2.7.4
Uninstalling ansible-2.7.4:
Successfully uninstalled ansible-2.7.4
Running setup.py install for ansible ... done
Successfully installed ansible-2.4.2.0
If you installed ansible with pip, the use the following command.
pip uninstall ansible
NOTE after you use it still possible to run ansible and get the help commands which shows that it is not uninstalled properly. See https://github.com/ansible/ansible/issues/46337.
Required to execute the command as root.
Edit:
According to the pip website (https://pip.pypa.io/en/stable/installing), I should already have pip installed with my Python version 2.9.7, but I assumed that I don't because of the error message.
I then attempted to install pip by downloading get-pip.py. It was successful but I got the messages:
Found existing installation: pip 1.3.1
Uninstalling pip-1.3.1:
Successfully uninstalled pip-1.3.1
Successfully installed pip-8.1.1 wheel-0.29.0
So it seems I did have a version of pip, so I'm not sure why I was getting the error message described in my original post.
But when I tried to then pip install jupyter, I just get:
-bash: pip: command not found
again. Can someone tell me what I'm doing wrong please?
I need to install iPython Notebook. I already have Python (version 2.7.9) installed on my Macbook, running OS X (version 10.7.5).
After some initial investigation, I saw somebody say that I could just run:
pip install "ipython[notebook]"
When I did this however, I got:
-bash: pip: command not found
So do I have to install pip first? And then use pip to install the Notebook? I'm out of my depth and a little confused!
Okay so my problem was that pip was installed, but in a location that was not included in my $PATH variable.
One of the answers here is relevant.
I have ansible version 1.9 on my Centos 7 machine, but need to get version 1.9.2 as I'm running into compatibility issues with ansible and docker.
However, doing a yum update on the ansible package has no affect:
yum update -y ansible
No packages marked for update
How can I upgrade the package?
Edit:
I have upgraded the package using pip as suggested by #Eldad AK:
sudo pip install --upgrade ansible==1.9.2
And the upgrade appeared to be successful:
Successfully installed MarkupSafe-0.23 ansible-1.9.2 ecdsa-0.13 jinja2-2.8 paramiko-1.16.0 setuptools-20.7.0
However when i run the ansible executable and check the version, it's still at 1.9:
ansible --version
ansible 1.9 (devel affb66416f) last updated 2015/11/04 09:09:40 (GMT +100)
You can upgrade it using pip. Try
sudo pip install --upgrade ansible
This is how we update Ansible.
I hope this helps.
You probably have two versions of ansible installed:
1.9 installed via yum. Which is the one in your path and probably in /usr/bin/ansible.
1.9.2 installed via pip. Check /usr/lib/python-version/site-packages/, I guess there is an ansible-1.9.2-* directory there.
You can either uninstall the first one or include the second one in you PATH with a higher precedence.
A quick and dirty fix would be:
mv /usr/bin/ansible /usr/bin/ansible1.9 && mv /usr/bin/ansible-playbook /usr/bin/ansible-playbook1.9
ln -s /usr/lib/python-<version>/ansible-1.9.2-py[...].egg/EGG/scripts/ansible /usr/bin/ansible
ln -s /usr/lib/python-<version>/ansible-1.9.2-py[...].egg/EGG/scripts/ansible-playbook /usr/bin/ansible-playbook
sudo python -m pip uninstall ansible
sudo python -m pip install ansible
tl;dr = How do OS X users recommend working around this permissions error?
I'm on OS X 10.10.1 and I recently installed Ansible running the following:
sudo pip install ansible --quiet
sudo pip install ansible --upgrade
I want to start off with a galaxy role to install homebrew and went to run this one with the following error:
$ ansible-galaxy install geerlingguy.homebrew
- downloading role 'homebrew', owned by geerlingguy
- downloading role from https://github.com/geerlingguy/ansible-role-homebrew/archive/1.0.1.tar.gz
- extracting geerlingguy.homebrew to /etc/ansible/roles/geerlingguy.homebrew
- error: you do not have permission to modify files in /etc/ansible/roles/geerlingguy.homebrew
- geerlingguy.homebrew was NOT installed successfully.
- you can use --ignore-errors to skip failed roles.
While I see /etc is owned by root, I don't see any notes in documentation saying I should chmod anything.
For reference:
$ ansible --version
ansible 1.8.2
configured module search path = None
Is this expected or is my installation somehow wrong?
The default location for roles is /etc/ansible/roles (for version <= 2.3. Since v2.4, the default location has changed to ~/.ansible/roles/, an issue has been raised). You need to specify --roles-path when using ansible-galaxy. Here's what ansible-galaxy install --help says:
-p ROLES_PATH, --roles-path=ROLES_PATH
The path to the directory containing your roles. The
default is the roles_path configured in your
ansible.cfg file (/etc/ansible/roles if not
configured)
You can also set roles_path in ansible.cfg; see the documentation for details.
Or you can use brew to install ansible. To do it you would need to run:
brew install ansible
If you had any previous installations, it is possible that you will see a message like this:
Error: The brew link step did not complete successfully The formula
built, but is not symlinked into /usr/local Could not symlink
bin/ansible Target /usr/local/bin/ansible already exists. You may want
to remove it: rm '/usr/local/bin/ansible'
To force the link and overwrite all conflicting files: brew link
--overwrite ansible
To list all files that would be deleted: brew link --overwrite
--dry-run ansible
Possible conflicting files are: /usr/local/bin/ansible
/usr/local/bin/ansible-console /usr/local/bin/ansible-doc
/usr/local/bin/ansible-galaxy /usr/local/bin/ansible-playbook
/usr/local/bin/ansible-pull /usr/local/bin/ansible-vault
So, run brew link --overwrite ansible to fix that. And now you will be able to install any roles without sudo.
Example:
ยป ansible-galaxy install bennojoy.redis
- downloading role 'redis', owned by bennojoy
- downloading role from https://github.com/bennojoy/redis/archive/master.tar.gz
- extracting bennojoy.redis to /usr/local/etc/ansible/roles/bennojoy.redis
- bennojoy.redis was installed successfully
As I saw you used "sudo" to install Ansible, I suppose it shall be OK to continue using "sudo" for ansible-galaxy installation. And that's what I just did.