# Installing pip packages into a virtualenv - where are they?

**URL:** <https://forum.ansible.com/t/installing-pip-packages-into-a-virtualenv-where-are-they/18137>\
**Category:** Ansible Project\
**Created:** [April 30, 2015, 2:49am UTC](https://forum.ansible.com/t/installing-pip-packages-into-a-virtualenv-where-are-they/18137 "2015-04-30T02:49:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Toby\_Hobson](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@Toby\_Hobson](https://forum.ansible.com/u/Toby_Hobson)\
**Post date:** [April 30, 2015, 2:49am UTC](https://forum.ansible.com/t/installing-pip-packages-into-a-virtualenv-where-are-they/18137/1 "2015-04-30T02:49:41Z")

</div>

I’m running ansible stable-1.9 (from git)

I have a playbook task which looks like this:

- name: Install virtualenv

easy\_install: name=virtualenv executable=easy\_install

- name: Setup pip packages  
pip: name={{item}} virtualenv=/home/ec2-user/scrapy virtualenv\_command=virtualenv executable=pip virtualenv\_site\_packages=yes extra\_args=“–allow-external”  
with\_items:
- scrapy
- pika  
…

When I run the playbook I see:

TASK: [Install virtualenv] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ok: [[ec2-54-78-26-101.eu-west-1.compute.amazonaws.com](http://ec2-54-78-26-101.eu-west-1.compute.amazonaws.com)]

TASK: [Setup pip packages] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

ok: [[ec2-54-78-26-101.eu-west-1.compute.amazonaws.com](http://ec2-54-78-26-101.eu-west-1.compute.amazonaws.com)] =\> (item=scrapy)

ok: [[ec2-54-78-26-101.eu-west-1.compute.amazonaws.com](http://ec2-54-78-26-101.eu-west-1.compute.amazonaws.com)] =\> (item=pika)

…

PLAY RECAP \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

[ec2-54-78-26-101.eu-west-1.compute.amazonaws.com](http://ec2-54-78-26-101.eu-west-1.compute.amazonaws.com) : ok=5 changed=0 unreachable=0 failed=0

However when I log into the server and activate the virtualenv I see none of the packages that ansible reports as installed:

$ source scrapy/bin/activate

(scrapy)[ec2-user]$ pip freeze

(none of the installed packages are listed)

What is really strange is that the packages don’t seem to be anywhere on the server i.e

$ cd /  
$ sudo find . | grep -i pika  
$

What am I missing here?

---

<div class="post-metadata">

**Author:** ![Toby\_Hobson](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@Toby\_Hobson](https://forum.ansible.com/u/Toby_Hobson)\
**Post date:** [April 30, 2015, 3:08am UTC](https://forum.ansible.com/t/installing-pip-packages-into-a-virtualenv-where-are-they/18137/2 "2015-04-30T03:08:09Z")

</div>

As a follow up, it seems if I drop the extra\_args parameter some packages are installed, except of course those packages that need the --allow-external flag. However when using this flag everything is reported as installed successfully but it seems the packages are actually skipped. Is this a known bug? I’m using 1.9.1 but I also tried the latest head code and got the same

---

<div class="post-metadata">

**Author:** ![Toby\_Hobson](https://avatars.discourse-cdn.com/v4/letter/t/7993a0/32.png) [@Toby\_Hobson](https://forum.ansible.com/u/Toby_Hobson)\
**Post date:** [April 30, 2015, 3:41am UTC](https://forum.ansible.com/t/installing-pip-packages-into-a-virtualenv-where-are-they/18137/3 "2015-04-30T03:41:53Z")

</div>

I got to the bottom of this:

I forgot to add the package name to allow-external i.e.

extra\_args=“–allow-external mysql-connector-python”

Now everything works as expected. I would still suggest that there is a (minor) bug if ansible reports a package is successfully installed when in fact it is not. What do you guys think?

---

<div class="post-metadata">

**Author:** ![Yassen\_Damyanov](https://avatars.discourse-cdn.com/v4/letter/y/9fc29f/32.png) [@Yassen\_Damyanov](https://forum.ansible.com/u/Yassen_Damyanov)\
**Post date:** [April 30, 2015, 6:06am UTC](https://forum.ansible.com/t/installing-pip-packages-into-a-virtualenv-where-are-they/18137/4 "2015-04-30T06:06:13Z")

</div>

Toby, not really a reply to your searches but just an idea:  
why not bootstrap pip via get-pip.py ([https://bootstrap.pypa.io/get-pip.py](https://bootstrap.pypa.io/get-pip.py)) and then use pip to install virtualenv and anything else?  
-Y.
