It'll be whichever installed ansible is first in your PATH and is
executable.

Here's a simple example:

$ echo $PATH
/usr/local/bin:/usr/bin

$ ll /usr/local/bin/wtf /usr/bin/wtf
-rwxr-xr-x 1 root root 35 Aug  9 23:48 /usr/bin/wtf*
-rwxr-xr-x 1 root root 41 Aug  9 23:48 /usr/local/bin/wtf*

$ cat /usr/local/bin/wtf /usr/bin/wtf
#!/bin/sh
echo We are in: /usr/local/bin
$ cat /usr/bin/wtf
#!/bin/sh
echo We are in: /usr/bin

$ wtf
We are in: /usr/local/bin

Swap the order in the PATH:

$ export PATH=/usr/bin:/usr/local/bin
$ wtf
We are in: /usr/bin

Make the closest script non-executable:

$ sudo chmod -x /usr/bin/wtf
$ wtf
We are in: /usr/local/bin

If you're pip-installing things ideally you want to do that in a Python
virtual environment (venv) so you don't trample over system Python modules.
Bonus of using venv is then when you toggle that venv 'on' the version
executed is largely taken care of for you.

See https://www.redhat.com/sysadmin/python-venv-ansible,
https://www.cbtnuggets.com/blog/technology/devops/how-to-install-ansible-in-a-python-virtual-environment
or many of the other how-tos for references.


On Wed, 9 Aug 2023 at 23:16, dmastrop <[email protected]> wrote:

> hi
>
> I have 2 versions of ansible installed on my Mac.(it was not intentional)
>
> One version was not installed through pip and the other version was
> installed through pip.
>
> I had to manually fix some permissions issues and now that those are
> addressed my terminal (VSCode) invokes the older version rather than the
> newer version.
>
> *What determines which version is run when there are multiple versions on
> a computer?*
> (from what I have read, pip does not install an ansible.cfg file and I
> don't know if that is where the setting is)
>
>
> I thought it might be the $PATH in the terminal but the path includes both
> versions.
>
>
> this is the version ansible 3.7.9(core 2.11.12). This was not installed
> through pip
>
>
>  % ansible --version
>
> [DEPRECATION WARNING]: Ansible will require Python 3.8 or newer on the
> controller starting with Ansible 2.12. Current
>
> *version: 3.7.9 *(v3.7.9:13c94747c7, Aug 15 2020, 01:31:08) [Clang 6.0
> (clang-600.0.57)]. This feature will be removed
>
> from ansible-core in version 2.12. Deprecation warnings can be disabled by
> setting deprecation_warnings=False in
>
> ansible.cfg.
>
> *ansible [core 2.11.12] *
>
>   config file = None
>
>   configured module search path =
> ['/Users/davemastropolo/.ansible/plugins/modules',
> '/usr/share/ansible/plugins/modules']
>
>   ansible python module location =
> /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible
>
>   ansible collection location =
> /Users/davemastropolo/.ansible/collections:/usr/share/ansible/collections
>
>   executable location =
> /Library/Frameworks/Python.framework/Versions/3.7/bin//ansible
>
>   python version = 3.7.9 (v3.7.9:13c94747c7, Aug 15 2020, 01:31:08) [Clang
> 6.0 (clang-600.0.57)]
>
>   jinja version = 3.1.2
>
>   libyaml = True
>
>
>
>
> this (below) is the newer version installed through pip:
>
> this *was* invoked through the terminal prior to fixing the permission
> issue on one of the directories (it was invoked but failing  due to the
> permission issue)
>
>
> Once the permission issue was addressed, ansible now invokes the older
> version (above)
>
>
>
>  % python3 -m pip list
> Package      Version
> ------------ --------
>
> *ansible      8.2.0ansible-core 2.15.2*
> certifi      2023.5.7
> cffi         1.15.1
> cryptography 41.0.3
> Jinja2       3.1.2
> MarkupSafe   2.1.3
> packaging    23.1
> pip          23.1.2
> pycparser    2.21
> PyYAML       6.0.1
> resolvelib   1.0.1
> setuptools   65.5.0
>
>
>
> warm regards
>
> Dave
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/158f2e5f-0a55-4a18-98e5-cbadde94a98fn%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/158f2e5f-0a55-4a18-98e5-cbadde94a98fn%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAKtKohQnznVbABiLsq4Qsco%2BfyRUEyb9Cvf_X7qahy7iOEoB_Q%40mail.gmail.com.

Reply via email to