# Installing python dependencies

**URL:** <https://forum.ansible.com/t/installing-python-dependencies/29877>\
**Category:** AWX Project\
**Tags:** vmware\
**Created:** [March 13, 2019, 9:29pm UTC](https://forum.ansible.com/t/installing-python-dependencies/29877 "2019-03-13T21:29:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Alberghini](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mike_alberghini/32/8855_2.png) [@Mike\_Alberghini](https://forum.ansible.com/u/Mike_Alberghini)\
**Post date:** [March 13, 2019, 9:29pm UTC](https://forum.ansible.com/t/installing-python-dependencies/29877/1 "2019-03-13T21:29:41Z")

</div>

The vmware\_category\_facts module requires the vsphere-automation-sdk for python from [https://github.com/vmware/vsphere-automation-sdk-python](https://github.com/vmware/vsphere-automation-sdk-python)

A straight up pip install using the pip module and git didn’t seem to work. I wound up having to install all the sub modules using a pip task that targeted them by direct url:

tasks:

- name: Install vsphere sdk  
pip:  
name:
- pyVmomi \>= 6.7
- suds-jurko
- [https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vapi-runtime/vapi\_runtime-2.10.2-py2.py3-none-any.whl](https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vapi-runtime/vapi_runtime-2.10.2-py2.py3-none-any.whl)
- [https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vapi-common-client/vapi\_common\_client-2.10.2-py2.py3-none-any.whl](https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vapi-common-client/vapi_common_client-2.10.2-py2.py3-none-any.whl)
- [https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vapi-client-bindings/vapi\_client\_bindings-1.5.0-py2.py3-none-any.whl](https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vapi-client-bindings/vapi_client_bindings-1.5.0-py2.py3-none-any.whl)
- [https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vmc-client-bindings/vmc\_client\_bindings-1.3.1-py2.py3-none-any.whl](https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vmc-client-bindings/vmc_client_bindings-1.3.1-py2.py3-none-any.whl)
- [https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/nsx-python-sdk/nsx\_python\_sdk-2.3.0.0.2.11053635-py2.py3-none-any.whl](https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/nsx-python-sdk/nsx_python_sdk-2.3.0.0.2.11053635-py2.py3-none-any.whl)
- [https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/nsx-policy-python-sdk/nsx\_policy\_python\_sdk-2.3.0.0.2.11053635-py2.py3-none-any.whl](https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/nsx-policy-python-sdk/nsx_policy_python_sdk-2.3.0.0.2.11053635-py2.py3-none-any.whl)
- [https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vmc-app-python-sdk/vmc\_app\_python\_sdk-2.3.0.0.2.11053635-py2.py3-none-any.whl](https://github.com/vmware/vsphere-automation-sdk-python/raw/master/lib/vmc-app-python-sdk/vmc_app_python_sdk-2.3.0.0.2.11053635-py2.py3-none-any.whl)

Is there a better way to do this? It seems less than perfect.

Mike

---

<div class="post-metadata">

**Author:** ![Steven\_Bateman](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@Steven\_Bateman](https://forum.ansible.com/u/Steven_Bateman)\
**Post date:** [March 14, 2019, 2:48pm UTC](https://forum.ansible.com/t/installing-python-dependencies/29877/2 "2019-03-14T14:48:55Z")

</div>

Mike,

Your best option is most likely using a custom virtual environment for your playbook, or alternately adding these modules to the default virtual environment. The below link is comprehensive for setting them up, but the caveat is you now have to manage custom AWX images via Docker.

[https://github.com/ansible/awx/blob/devel/docs/custom\_virtualenvs.md](https://github.com/ansible/awx/blob/devel/docs/custom_virtualenvs.md)

Here’s an example Jinja2 Dockerfile that I use that’s fed into an Ansible playbook. It references requirements.txt files managed by the tenant teams that want their own venvs. We also install Mitogen as a strategy plugin, so if you don’t need/want that you can ignore those lines.

`

```auto
FROM ansible/awx_task:{{ awx_version }}

USER root
ADD . /tmp
RUN yum install -y gcc python-devel
RUN update-ca-trust

RUN /var/lib/awx/venv/ansible/bin/pip install -q psutil python-memcached mitogen
RUN cp /tmp/playbook/build_image/files/mitogen_plugins/* /usr/lib/python2.7/site-packages/ansible/plugins/strategy

{% for venv_name in venv_list %}
RUN virtualenv /var/lib/awx/venv/{{ venv_name }} \
 && /var/lib/awx/venv/{{ venv_name }}/bin/pip install -q -r /tmp/custom_venvs/{{ venv_name }}-requirements.txt \
 && /var/lib/awx/venv/{{ venv_name }}/bin/pip install -q psutil python-memcached mitogen
RUN cp /tmp/playbook/build_image/files/mitogen_plugins/* /var/lib/awx/venv/{{ venv_name }}/lib/python2.7/site-packages/ansible/plugins/strategy
{% endfor %}

RUN yum remove -y gcc python-devel && yum clean all

```

`
