# Pip module issue - install seems to hang when installing from a requirements file

**URL:** <https://forum.ansible.com/t/pip-module-issue-install-seems-to-hang-when-installing-from-a-requirements-file/13297>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [August 14, 2013, 3:32am UTC](https://forum.ansible.com/t/pip-module-issue-install-seems-to-hang-when-installing-from-a-requirements-file/13297 "2013-08-14T03:32:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_brooks](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@Jason\_brooks](https://forum.ansible.com/u/Jason_brooks)\
**Post date:** [August 14, 2013, 3:32am UTC](https://forum.ansible.com/t/pip-module-issue-install-seems-to-hang-when-installing-from-a-requirements-file/13297/1 "2013-08-14T03:32:54Z")

</div>

Can anyone help with this issue…

When log into the remote machine and manually pip install -r production.txt it works fine

**In my playbook i have:**

- name: Update the virtualenv with production requirements.  
pip: requirements=${project\_root}/myapp/deps/production.txt virtualenv=${project\_root}/env extra\_args=‘–exists-action w’

**Also Tried:**

- name: pip install prod requirements  
command: “${project\_root}/env/bin/pip install -r ${project\_root}/myapp/deps/production.txt --exists-action w --log ${project\_root}/downloads/mypip\_log.txt”

ansible 1.2.2  
python 2.7.4  
pip 1.4.1

remote machine - Ubuntu 13.04

**ansible log:**

TASK: [Upgrade the virtualenv with prod requirements.] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
\<198.58.115.201\> ESTABLISH CONNECTION FOR USER: root  
\<198.58.115.201\> EXEC [‘sshpass’, ‘-d9’, ‘ssh’, ‘-tt’, ‘-q’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/tmp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘GSSAPIAuthentication=no’, ‘-o’, ‘PubkeyAuthentication=no’, ‘-o’, ‘User=root’, ‘-o’, ‘ConnectTimeout=999999’, ‘198.58.115.201’, “/bin/sh -c ‘mkdir -p /tmp/ansible-1376450420.48-23411754031827 && chmod a+rx /tmp/ansible-1376450420.48-23411754031827 && echo /tmp/ansible-1376450420.48-23411754031827’”]  
\<198.58.115.201\> REMOTE\_MODULE pip requirements=/home/myuser/projects/myapp/deps/production.txt virtualenv=/home/myuser/projects/env extra\_args=‘–exists-action w --log ~/pip\_prod1\_log.txt’  
\<198.58.115.201\> PUT /tmp/tmpShRoOh TO /tmp/ansible-1376450420.48-23411754031827/pip  
\<198.58.115.201\> EXEC [‘sshpass’, ‘-d9’, ‘ssh’, ‘-tt’, ‘-q’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/tmp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘GSSAPIAuthentication=no’, ‘-o’, ‘PubkeyAuthentication=no’, ‘-o’, ‘User=root’, ‘-o’, ‘ConnectTimeout=999999’, ‘198.58.115.201’, “/bin/sh -c ‘chmod a+r /tmp/ansible-1376450420.48-23411754031827/pip’”]  
\<198.58.115.201\> EXEC [‘sshpass’, ‘-d9’, ‘ssh’, ‘-tt’, ‘-q’, ‘-o’, ‘ControlMaster=auto’, ‘-o’, ‘ControlPersist=60s’, ‘-o’, ‘ControlPath=/tmp/ansible-ssh-%h-%p-%r’, ‘-o’, ‘Port=22’, ‘-o’, ‘GSSAPIAuthentication=no’, ‘-o’, ‘PubkeyAuthentication=no’, ‘-o’, ‘User=root’, ‘-o’, ‘ConnectTimeout=999999’, ‘198.58.115.201’, u’/bin/sh -c 'sudo -k && sudo -H -S -p “[sudo via ansible, key=ttlhctamxfmseklxzjnlbwbbtkptumux] password: " -u myuser /bin/sh -c '”'“'/usr/bin/python /tmp/ansible-1376450420.48-23411754031827/pip'”'"''']

**pip log:**

it looks like the install hangs when it gets here

Downloading/unpacking xhtml2pdf==0.0.3 (from -r /home/myuser/projects/myapp/deps/production.txt (line 15))

Getting page [https://pypi.python.org/simple/xhtml2pdf/](https://pypi.python.org/simple/xhtml2pdf/)  
URLs to search for versions for xhtml2pdf==0.0.3 (from -r /home/myuser/projects/myapp/deps/production.txt (line 15)):

- [https://pypi.python.org/simple/xhtml2pdf/0.0.3](https://pypi.python.org/simple/xhtml2pdf/0.0.3)
- [https://pypi.python.org/simple/xhtml2pdf/](https://pypi.python.org/simple/xhtml2pdf/)  
Getting page [https://pypi.python.org/simple/xhtml2pdf/0.0.3](https://pypi.python.org/simple/xhtml2pdf/0.0.3)  
Could not fetch URL [https://pypi.python.org/simple/xhtml2pdf/0.0.3:](https://pypi.python.org/simple/xhtml2pdf/0.0.3:) HTTP Error 404: Not Found (xhtml2pdf/0.0.3)  
Will skip URL [https://pypi.python.org/simple/xhtml2pdf/0.0.3](https://pypi.python.org/simple/xhtml2pdf/0.0.3) when looking for download links for xhtml2pdf==0.0.3 (from -r /home/myuser/projects/myapp/deps/production.txt (line 15))  
Analyzing links from page [https://pypi.python.org/simple/xhtml2pdf/](https://pypi.python.org/simple/xhtml2pdf/)  
Found link [https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.1.tar.gz#md5=9f83a2bcb67858aca9e058761f3bea7b](https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.1.tar.gz#md5=9f83a2bcb67858aca9e058761f3bea7b) (from [https://pypi.python.org/simple/xhtml2pdf/](https://pypi.python.org/simple/xhtml2pdf/)), version: 0.0.1  
Found link [https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.2.tar.gz#md5=d640ccb9470942fd2e6d3ae740c27dc1](https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.2.tar.gz#md5=d640ccb9470942fd2e6d3ae740c27dc1) (from [https://pypi.python.org/simple/xhtml2pdf/](https://pypi.python.org/simple/xhtml2pdf/)), version: 0.0.2  
Found link [https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.1.zip#md5=4ad41c845735ae14da99085311d84c00](https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.1.zip#md5=4ad41c845735ae14da99085311d84c00) (from [https://pypi.python.org/simple/xhtml2pdf/](https://pypi.python.org/simple/xhtml2pdf/)), version: 0.0.1  
Found link [https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.4.zip#md5=5f035cd6532bef99b7d35054caaa6ef7](https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.4.zip#md5=5f035cd6532bef99b7d35054caaa6ef7) (from [https://pypi.python.org/simple/xhtml2pdf/](https://pypi.python.org/simple/xhtml2pdf/)), version: 0.0.4  
Found link [https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.3.zip#md5=32599c74f26f57ebd002765741ec64f7](https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.3.zip#md5=32599c74f26f57ebd002765741ec64f7) (from [https://pypi.python.org/simple/xhtml2pdf/](https://pypi.python.org/simple/xhtml2pdf/)), version: 0.0.3  
Found link [https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.2.zip#md5=4047a8234eb6b77591d526dcb1f60161](https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.2.zip#md5=4047a8234eb6b77591d526dcb1f60161) (from [https://pypi.python.org/simple/xhtml2pdf/](https://pypi.python.org/simple/xhtml2pdf/)), version: 0.0.2  
Found link [https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.3.tar.gz#md5=13b0d6059b72c994473fddfa7a528451](https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.3.tar.gz#md5=13b0d6059b72c994473fddfa7a528451) (from [https://pypi.python.org/simple/xhtml2pdf/](https://pypi.python.org/simple/xhtml2pdf/)), version: 0.0.3  
Found link [https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.5.zip#md5=8db99aae8536436a2b7b0b3987197b99](https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.5.zip#md5=8db99aae8536436a2b7b0b3987197b99) (from [https://pypi.python.org/simple/xhtml2pdf/](https://pypi.python.org/simple/xhtml2pdf/)), version: 0.0.5  
Found link [https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.5.tar.gz#md5=1ef268b40c11bf966f7c6c5504299e3e](https://pypi.python.org/packages/source/x/xhtml2pdf/xhtml2pdf-0.0.5.tar.gz#md5=1ef268b40c11bf966f7c6c5504299e3e) (from [https://pypi.python.org/simple/xhtml2pdf/](https://pypi.python.org/simple/xhtml2pdf/)), version: 0.0.5

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 15, 2013, 1:44am UTC](https://forum.ansible.com/t/pip-module-issue-install-seems-to-hang-when-installing-from-a-requirements-file/13297/2 "2013-08-15T01:44:18Z")

</div>

Sounds like this is just a problem with the remote source timing out?

Remember to use {{ foo }} vs $foo BTW 🙂

---

<div class="post-metadata">

**Author:** ![Jason\_brooks](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@Jason\_brooks](https://forum.ansible.com/u/Jason_brooks)\
**Post date:** [August 15, 2013, 4:13am UTC](https://forum.ansible.com/t/pip-module-issue-install-seems-to-hang-when-installing-from-a-requirements-file/13297/3 "2013-08-15T04:13:34Z")

</div>

Thank you for the response. I initially thought it was a timeout issue but i have been able to pip install my requirements file multiple times manually on the remote server. I also wrote a python script that parsed my requirements file and pip installed each package individually. I called the script in my playbook and got it to work. But I rather not use the script as a workaround for the pip module.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [August 15, 2013, 12:30pm UTC](https://forum.ansible.com/t/pip-module-issue-install-seems-to-hang-when-installing-from-a-requirements-file/13297/4 "2013-08-15T12:30:21Z")

</div>

There are lots of people using the pip module, so I don’t know what’s going on on your end.

If you can help debug using hacking/test-module in the checkout that would be useful.

---

<div class="post-metadata">

**Author:** ![Jason\_brooks](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@Jason\_brooks](https://forum.ansible.com/u/Jason_brooks)\
**Post date:** [August 16, 2013, 4:27am UTC](https://forum.ansible.com/t/pip-module-issue-install-seems-to-hang-when-installing-from-a-requirements-file/13297/5 "2013-08-16T04:27:41Z")

</div>

i will try that. I have narrowed it down to these two packages in my requirements file…

> =1.7.7.1  
> -e git+https://github.com/staale/python-xlsx@976cb845080aeff5e5a748c9bd28128fc916d5ac#egg=python-xlsx

the pip install does not even attempt to install these packages…as there is no output in the pip log when I try these two individually as the only packages in the requirements file. However, i was able to get my entire requirements file to install successfully including these two packages when i tested it using localhost. It only seems to cause an issue on a remote machine and when they are in a requirements file. I have attempted it on both digital ocean and linode.

Going to keep looking at my environment and try from a different machine.

I appreciate your help

---

<div class="post-metadata">

**Author:** ![Matthias\_Kiefer](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Matthias\_Kiefer](https://forum.ansible.com/u/Matthias_Kiefer)\
**Post date:** [September 10, 2013, 12:00pm UTC](https://forum.ansible.com/t/pip-module-issue-install-seems-to-hang-when-installing-from-a-requirements-file/13297/6 "2013-09-10T12:00:57Z")

</div>

I had a similar problem that pip failed to reach [pypi.python.org](http://pypi.python.org) completely when called from ansible. The reason was that a proxy was needed on the remote host and the proxy to connect to was set in the environment variables http\_proxy and https\_proxy. Since sudo resets the environment for security reasons, the pip command run from ansible with sudo was not able to connect to [pypi.python.org](http://pypi.python.org).

You can solve this by adding the following line to the sudoers config:  
Defaults env\_keep += “http\_proxy https\_proxy”

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [September 10, 2013, 12:35pm UTC](https://forum.ansible.com/t/pip-module-issue-install-seems-to-hang-when-installing-from-a-requirements-file/13297/7 "2013-09-10T12:35:50Z")

</div>

See the “environment” parameter in Ansible for how to pass an arbitrary environment to any task.

[http://www.ansibleworks.com/docs/playbooks2.html#setting-the-environment-and-working-with-proxies](http://www.ansibleworks.com/docs/playbooks2.html#setting-the-environment-and-working-with-proxies)

This is better because it doesn’t rely on any pre-existing user configuration on the system, or trusting the user’s configuration.
