Thanks Will Yes it is using zsh (in the VSCode). The VSCode has a few extra items in the path in addition to the Mac Terminal but these are repeats.
I agree that just adding that to the front of the path is too risky. I know there's other stuff that is using the older python. I will set up an EC2 Mac instance and understand how this works. For now since this is a development/test environment I will simply set the path per terminal(s) when I need to invoke ansible using % export PATH=/Users/xxxxxx/Library/Python/3.11/bin:$PATH This seems to work ok I also don't think using the older version of ansible will be that detrimental to what I am running locally. I will leave the current PATH in the .zprofile and .zshrc as is until I work this out on the EC2 instance.... many thanks for your help warm regards Dave On Tuesday, August 15, 2023 at 3:39:50 PM UTC-7 Will McDonald wrote: > I don't have a Mac handy but your default shell is probably zsh. Outside > of Vscode, zsh will setup the PATH based on the following startup files: > https://zsh.sourceforge.io/Intro/intro_3.html > > Check which of those files exist in /Users/xxxxxx/ and contains logic to > set your PATH. If you add something like: > > export PATH=/Users/xxxxx/Library/Python/3.11/bin:$PATH > > ... toward the end of one of the right one of those init files (almost > certainly one of $ZDOTDIR/.zshenv, $ZDOTDIR/.zprofile, $ZDOTDIR/.zshrc) > that'll prepend /Users/xxxxx/Library/Python/3.11/bin to the front of your > PATH. VScode will probably then pick that up if you close and restart the > integrated terminal. > > You may need to figure out the order of execution in order to get your > PATH set correctly. No guarantees this won't break other Python-related > things and as stated previously, you should really be using the system > Python in an unadulterated state, then using Python venvs to localise stuff > and then you just activate the venv you need, when you need it. > > Personally I would recommend getting this working in an isolated > environment (a VM or Mac ec2 instance, whatever else you can rustle up) > first. Understand the moving parts, then configure your environment for > your needs cleanly. > > > > On Tue, 15 Aug 2023 at 18:57, dmastrop <[email protected]> wrote: > >> Thanks Will >> >> >> I found the binary for the pip installed latest version of ansible. >> It seems to finally work fine >> >> >> >> It is located here: >> >> */Users/xxxxx/Library/Python/3.11/bin* >> >> >> >> % ./ansible --version >> ansible [core 2.15.2] >> config file = None >> configured module search path = >> ['/Users/xxxxxx/.ansible/plugins/modules', >> '/usr/share/ansible/plugins/modules'] >> ansible python module location = >> /Users/xxxxxx/Library/Python/3.11/lib/python/site-packages/ansible >> ansible collection location = >> /Users/xxxxxx/.ansible/collections:/usr/share/ansible/collections >> executable location = ./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) >> jinja version = 3.1.2 >> libyaml = True >> >> >> >> >> My PATH is missing this directory >> >> >> *For VSCode terminal how can I add this to the beginning of my PATH. I >> can leave the older version on ansible in the PATH if I prepend >> this /Users/xxxxx/Library/Python/3.11/bin path to the beginning so that I >> don't need to make a lot of modifications.* >> >> >> I ask because I don't understand the docs explaining how to add to the >> PATH in VSCode. (they modify the JSON config file) >> >> As you can see I have a lot of repetition in the PATH as well. I don't >> know how that happened. >> >> >> >> Here is my current PATH >> >> >> >> /Users/xxxxx/google-cloud-sdk/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin/:/Users/xxxxx/google-cloud-sdk/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:/usr/local/sbin >> >> >> warm regards >> >> Dave >> >> On Wednesday, August 9, 2023 at 4:01:03 PM UTC-7 Will McDonald wrote: >> >>> 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/c3e694aa-5c34-4850-be87-c403bfcab0edn%40googlegroups.com >> >> <https://groups.google.com/d/msgid/ansible-project/c3e694aa-5c34-4850-be87-c403bfcab0edn%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/9a17cb51-7cc5-4162-9f30-7327d643ec9bn%40googlegroups.com.
