# Ansible not working with remote Python virtual environments on Mac

**URL:** <https://forum.ansible.com/t/ansible-not-working-with-remote-python-virtual-environments-on-mac/35989>\
**Category:** Ansible Project\
**Created:** [November 11, 2021, 5:08pm UTC](https://forum.ansible.com/t/ansible-not-working-with-remote-python-virtual-environments-on-mac/35989 "2021-11-11T17:08:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Spitzer](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@Mike\_Spitzer](https://forum.ansible.com/u/Mike_Spitzer)\
**Post date:** [November 11, 2021, 5:08pm UTC](https://forum.ansible.com/t/ansible-not-working-with-remote-python-virtual-environments-on-mac/35989/1 "2021-11-11T17:08:05Z")

</div>

All actions with the pip module (other than creating the venv) apply to the user context and not the venv on a Mac. The details below are for the pip module. Running the commands when logged into the system works as expected and using those commands with both the command and shell modules results in the same outcome as the pip module. There’s something different about the way it’s being interpreted through Ansible. The same role works fine in Linux. Have tried this on 2 different Macs, both running Catalina.

$ ansible --version  
ansible [core 2.11.6] config file = None configured module search path = [‘/Users/spitzer/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’] ansible python module location = /Users/spitzer/.virtualenvs/ansible460/lib/python3.8/site-packages/ansible ansible collection location = /Users/spitzer/.ansible/collections:/usr/share/ansible/collections executable location = /Users/spitzer/.virtualenvs/ansible460/bin/ansible python version = 3.8.12 (default, Sep 1 2021, 07:26:09) [Clang 11.0.3 (clang-1103.0.32.62)] jinja version = 3.0.1 libyaml = True

So, a minimal role to duplicate this is:

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [November 11, 2021, 9:47pm UTC](https://forum.ansible.com/t/ansible-not-working-with-remote-python-virtual-environments-on-mac/35989/2 "2021-11-11T21:47:02Z")

</div>

Drop the virtualenv command and try ‘python3 -m venv’ instead

---

<div class="post-metadata">

**Author:** ![Mike\_Spitzer](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@Mike\_Spitzer](https://forum.ansible.com/u/Mike_Spitzer)\
**Post date:** [November 18, 2021, 5:32pm UTC](https://forum.ansible.com/t/ansible-not-working-with-remote-python-virtual-environments-on-mac/35989/3 "2021-11-18T17:32:52Z")

</div>

Sorry for the late response on this. Running the -m venv and then -m pip works. Still doesn’t work with the built-in pip module, but at least this is a workaround.

Thanks
