# Dependency issue with azure.azcollection, Ansible installed via Homebrew

**URL:** <https://forum.ansible.com/t/dependency-issue-with-azure-azcollection-ansible-installed-via-homebrew/4174>\
**Category:** Get Help\
**Tags:** azure, collections\
**Created:** [March 1, 2024, 6:03pm UTC](https://forum.ansible.com/t/dependency-issue-with-azure-azcollection-ansible-installed-via-homebrew/4174 "2024-03-01T18:03:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jms1](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jms1/32/2255_2.png) [@jms1](https://forum.ansible.com/u/jms1)\
**Post date:** [March 1, 2024, 6:04pm UTC](https://forum.ansible.com/t/dependency-issue-with-azure-azcollection-ansible-installed-via-homebrew/4174/1 "2024-03-01T18:04:00Z")

</div>

I’m using Ansible on macOS, installed via [homebrew](https://brew.sh/). I’m trying to use `azure.azcollection`, it’s telling me …

```auto
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ModuleNotFoundError: No module named 'msrestazure'
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (ansible[azure] (azure >= 2.0.0)) on WORKSTATION's Python /usr/local/Cellar/ansible/9.2.0/libexec/bin/python. Please read the module documentation and install it in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter"}

```

⚠ I am _not_ a python expert. I’ve been programming since 1981 but haven’t needed to use python until ansible, so it would not surprise me to find that I’m missing some details that others might find obvious.

With that said, what I’m getting from the error message is …

- The `azure.azcollection` collection has dependencies which apparently were not installed by homebrew, even though `azure.azcollection` itself _was_ installed as part of `brew install ansible`.
- Installing python dependencies should be done in a “virtual environment”, to avoid making unintended changes to python files needed by the OS.

So I created and activated a virtual environment …

```auto
cd $WORK
pip3 -m venv venv
source venv/bin/activate

```

… then tried to install the dependencies within the `venv/` directory.

```auto
cd $( brew --prefix ansible )/libexec/lib/python3.12/site-packages/ansible_collections/azure/azcollection/
pip3 install requirements-azure.txt

```

It downloaded and installed a bunch of packages, however it didn’t install them under the `$WORK/venv/` directory, it installed them under `/usr/local/Cellar/ansible/9.2.0/libexec/lib/python3.12/site-packages/ansible_collections/azure/azcollection/`.

Am I mis-understanding how virtual environments work? _Should_ it have installed the packages under `$WORK/venv/`, or did it do “the right thing” and I don’t understand what it was _supposed_ to do?

Moving on … I then tried to run the playbook again, with the virtual environment still “active”.

```auto
cd $WORK
ansible-playbook xxx.yml

```

Same exact error message.

So my other question is … if the modules _were_ installed in the correct location above, does `ansible-playbook` not pay attention to the `VIRTUAL_ENV` environment variable (which _is_ still set), and it’s looking in some other location to find dependencies?

(Full disclosure: apparently I hadn’t run `brew update` in about two weeks, so this could also be an issue with outdated packages. `brew upgrade` is running in another window as I type this, once that finishes I’m going to try all this again and see if it helps.)
