# How to use pip module wiht multiple packages and versions

**URL:** <https://forum.ansible.com/t/how-to-use-pip-module-wiht-multiple-packages-and-versions/21897>\
**Category:** Ansible Project\
**Created:** [June 29, 2016, 9:41pm UTC](https://forum.ansible.com/t/how-to-use-pip-module-wiht-multiple-packages-and-versions/21897 "2016-06-29T21:41:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tiglath](https://avatars.discourse-cdn.com/v4/letter/t/df705f/32.png) [@Tiglath](https://forum.ansible.com/u/Tiglath)\
**Post date:** [June 29, 2016, 9:41pm UTC](https://forum.ansible.com/t/how-to-use-pip-module-wiht-multiple-packages-and-versions/21897/1 "2016-06-29T21:41:20Z")

</div>

I have a long list packages to install in the fashion:

pip install ==

I can see that you can do

```auto
pip: name={{ item }} state=present
with_items:
  - <package>
  - <package>
   ...

But how can I specify the version in a loop?   

Sorry, new at this...

Many thanks

```

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [June 30, 2016, 6:02am UTC](https://forum.ansible.com/t/how-to-use-pip-module-wiht-multiple-packages-and-versions/21897/2 "2016-06-30T06:02:20Z")

</div>

I do this

- pip:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name={{ item.name }}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;version={{ item.version | default(omit) }}  
&nbsp;&nbsp;&nbsp;with\_items:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: pack1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;version: 1.1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: pack2  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: pack3  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- name: pack4  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;version: 5.0

As you can see, you'll be able to mix packages with or without version requirement.

---

<div class="post-metadata">

**Author:** ![Tiglath](https://avatars.discourse-cdn.com/v4/letter/t/df705f/32.png) [@Tiglath](https://forum.ansible.com/u/Tiglath)\
**Post date:** [June 30, 2016, 1:48pm UTC](https://forum.ansible.com/t/how-to-use-pip-module-wiht-multiple-packages-and-versions/21897/3 "2016-06-30T13:48:22Z")

</div>

That is great.

Gratitude!
