# Should pip still use /usr/bin/python if the ansible\_python\_interpreter env var is set to a virtualenv

**URL:** <https://forum.ansible.com/t/should-pip-still-use-usr-bin-python-if-the-ansible-python-interpreter-env-var-is-set-to-a-virtualenv/26540>\
**Category:** Ansible Project\
**Created:** [January 23, 2018, 12:59pm UTC](https://forum.ansible.com/t/should-pip-still-use-usr-bin-python-if-the-ansible-python-interpreter-env-var-is-set-to-a-virtualenv/26540 "2018-01-23T12:59:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wajdi\_Al-Hawari](https://avatars.discourse-cdn.com/v4/letter/w/87869e/32.png) [@Wajdi\_Al-Hawari](https://forum.ansible.com/u/Wajdi_Al-Hawari)\
**Post date:** [January 23, 2018, 12:59pm UTC](https://forum.ansible.com/t/should-pip-still-use-usr-bin-python-if-the-ansible-python-interpreter-env-var-is-set-to-a-virtualenv/26540/1 "2018-01-23T12:59:58Z")

</div>

The Scenario:

I have encountered an issue that I first drafted as a bug, but before I post it, I wanted to ask about it here first.

The scenario I’m facing is wanting to run my playbook without explicitly setting a virtualenv in my pip module. So, instead I’m using the ansible\_python\_interpreter to point to the python interpreter I want to use.

example call: ansible-playbook -i inventory --connection=local playbook.yml -e ansible\_python\_interpreter=/home/user/foo\_proj/venv

I noticed that when running my playbook with my python interpreter set to /home/user/foo\_proj/venv/, my expectation was for the venv to be within that context using /home/user/foo\_proj/venv/bin/pip. It, however instead was using /usr/local/bin/pip3 per the small snippet of my output:

```auto
ok: [localhost] => {
    "changed": false, 
    "cmd": "/usr/local/bin/pip3 install docker-compose", 
    "invocation": {
        "module_args": {

```

I do have a growing suspicion that the intention of this “ansible\_python\_interpreter” environment variable is not necessarily meant for virtual environments (meaning my supposed bug is invalid) but specific locations of the Python executable you want to use, thus, in turn using its respecting /usr/bin/pipX (X being the version).

It is fairly clear even from the code [here](https://github.com/ansible/ansible/blob/6233daaa446993e4820f0eaa83ffdeb673dbcced/lib/ansible/modules/packaging/language/pip.py#L299) that the behaviour is to look for /usr/bin/pip.

The question:

So, my question is whether using the ansible\_python\_interpreter should in fact get the pip module to use the respective environment pip, or is it as specified in the code not intended to change the pip module path to the virtualenv pip, but rather to the system level pip for the version of Python being specified by ansible\_python\_interpreter?

---

<div class="post-metadata">

**Author:** ![Wajdi\_Al-Hawari](https://avatars.discourse-cdn.com/v4/letter/w/87869e/32.png) [@Wajdi\_Al-Hawari](https://forum.ansible.com/u/Wajdi_Al-Hawari)\
**Post date:** [January 23, 2018, 1:01pm UTC](https://forum.ansible.com/t/should-pip-still-use-usr-bin-python-if-the-ansible-python-interpreter-env-var-is-set-to-a-virtualenv/26540/2 "2018-01-23T13:01:51Z")

</div>

I forgot to specify my Ansible version. I am using: 2.4.2.0
