help with ansible Mac installation

hi all,

I have installed ansible on Cloud9 and EC2 ubuntu instances but I am having trouble with the Mac installation.
It might be because I installed it using
sudo pip3 install ansible

when I should have used
python3 -m pip install --user ansible ?

I tried running the python3 above but it stated everything is ok (and on python 3.11)

It was initially linked to an older version of python (3.7) but is now linked to the proper python module location.

However I cannot run anything without sudo privileges

Here is the sudo ansible --version

sudo ansible --version
Password:
ansible [core 2.15.2]
config file = None
configured module search path = [‘/Users/xxxxx/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]
ansible python module location = /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/ansible
ansible collection location = /Users/xxxxx/.ansible/collections:/usr/share/ansible/collections
executable location = /Library/Frameworks/Python.framework/Versions/3.11/bin/ansible
python version = 3.11.4 (v3.11.4:d2340ef257, Jun 6 2023, 19:15:51) [Clang 13.0.0 (clang-1300.0.29.30)] (/Library/Frameworks/Python.framework/Versions/3.11/bin/python3.11)
jinja version = 3.1.2
libyaml = True

Here is the ansible --version without sudo. (see bottom)
It is linking to the old python version in the traceback. Not sure why
I tried getting into the tmp directory below as my local user on the Mac (with administrator privileges) but can’t get into it. It is owned by root.
Both of the exceptions are related to this tmp directory permissions issue…

The tmp directory is
Users/xxxx/.ansible/tmp/ansible-local-506222opmhr9x’

xxxx is my local user name (logged in user). I am administrator on the Mac.

Does anyone know what I need to do to fix this permissions issue?

warmest regards
Dave

% ansible --version

Unhandled error:

Traceback (most recent call last):

File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py”, line 605, in update_config_data

value, origin = self.get_config_value_and_origin(config, configfile)

File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py”, line 543, in get_config_value_and_origin

value = ensure_type(value, defs[config].get(‘type’), origin=origin)

File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py”, line 124, in ensure_type

value = tempfile.mkdtemp(prefix=prefix, dir=value)

File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tempfile.py”, line 366, in mkdtemp

_os.mkdir(file, 0o700)

PermissionError: [Errno 13] Permission denied: ‘/Users/xxxx/.ansible/tmp/ansible-local-506222opmhr9x’

Traceback (most recent call last):

File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py”, line 605, in update_config_data

value, origin = self.get_config_value_and_origin(config, configfile)

File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py”, line 543, in get_config_value_and_origin

value = ensure_type(value, defs[config].get(‘type’), origin=origin)

File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py”, line 124, in ensure_type

value = tempfile.mkdtemp(prefix=prefix, dir=value)

File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tempfile.py”, line 366, in mkdtemp

_os.mkdir(file, 0o700)

PermissionError: [Errno 13] Permission denied: '/Users/xxxx/.ansible/tmp/ansible-local-506222opmhr9x

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File “/Library/Frameworks/Python.framework/Versions/3.7/bin//ansible”, line 63, in

import ansible.constants as C

File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/constants.py”, line 181, in

config = ConfigManager()

File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py”, line 310, in init

self.update_config_data()

File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/ansible/config/manager.py”, line 617, in update_config_data

raise AnsibleError(“Invalid settings supplied for %s: %s\n” % (config, to_native(e)), orig_exc=e)

ansible.errors.AnsibleError: Invalid settings supplied for DEFAULT_LOCAL_TMP: [Errno 13] Permission denied: ‘/Users/xxxx/.ansible/tmp/ansible-local-506222opmhr9x’

. [Errno 13] Permission denied: ‘/Users/xxxx/.ansible/tmp/ansible-local-506222opmhr9x’

Hii,

I would recommend following the installation instructions from
https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-and-upgrading-ansible-with-pip