# Ansible installation using pip broken?

**URL:** <https://forum.ansible.com/t/ansible-installation-using-pip-broken/20673>\
**Category:** Ansible Developer\
**Tags:** ubuntu\
**Created:** [February 25, 2016, 12:56am UTC](https://forum.ansible.com/t/ansible-installation-using-pip-broken/20673 "2016-02-25T00:56:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![angel](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@angel](https://forum.ansible.com/u/angel)\
**Post date:** [February 25, 2016, 12:56am UTC](https://forum.ansible.com/t/ansible-installation-using-pip-broken/20673/1 "2016-02-25T00:56:38Z")

</div>

Hi there,

I am trying to install Ansible within a Docker container (plain Ubuntu 14.04) to be used as a test environment.  
The Python version is managed by `pyenv`, and I am using `pip` to install Ansible. This is the output of the “pip freeze” command after installing Ansible:

```auto

root@7e408538fd38:/usr/src/myapp# pip freeze
ansible==2.0.0.2
chardet==2.3.0
colorama==0.2.5
ecdsa==0.13
html5lib==0.999
httplib2==0.8
Jinja2==2.8
MarkupSafe==0.23
paramiko==1.16.0
pycrypto==2.6.1
python-distutils-extra==2.28
PyYAML==3.11
requests==2.2.1
six==1.5.2
urllib3==1.7.1
wheel==0.24.0

```

When I run one of my playbooks that uses the `apt` module, I get the following error indicating that the `python-apt` module is missing:

```auto
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "Could not import python modules: apt, apt_pkg. Please install python-apt package."}

```

When trying to install python-apt module manually using pip, I get an error about more modules missing:

```auto

root@c833f66ef7c0:/usr/src/myapp# pip install python-apt
Collecting python-apt
Downloading python-apt-0.7.8.tar.bz2 (49kB)
100% |################################| 53kB 84kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-y4ASYs/python-apt/setup.py", line 6, in <module>
from DistUtilsExtra.command import *
ImportError: No module named DistUtilsExtra.command

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-y4ASYs/python-apt

```

I would expect these dependencies to me managed by pip when installing the Ansible package. Am I missing anything?

Any input would be appreciated.  
Thanks for your help.

Angel

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 25, 2016, 1:05am UTC](https://forum.ansible.com/t/ansible-installation-using-pip-broken/20673/2 "2016-02-25T01:05:54Z")

</div>

python-apt is a dependency not of ansible master, but of the apt module, it must be installed on the ‘target’ machine not on the ‘master’.

The module itself should try to install it automatically, but it seems there are issues with that in your systems.

---

<div class="post-metadata">

**Author:** ![angel](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@angel](https://forum.ansible.com/u/angel)\
**Post date:** [February 25, 2016, 3:10am UTC](https://forum.ansible.com/t/ansible-installation-using-pip-broken/20673/3 "2016-02-25T03:10:48Z")

</div>

Thanks Brian.

You are right. The module installs the python-apt package on the target instance, but the module will only be available to the Ubuntu Python installation (/usr/lib/python2.7/dist-packages/apt/), not the one managed by pyenv.

I tried to install the python-apt module using pip (within the pyenv-managed Python installation), but get a dependency error:

root@617d09e567c1:/usr/src/myapp# pip install python-apt  
Collecting python-apt  
Downloading python-apt-0.7.8.tar.bz2 (49kB)  
100% |################################| 53kB 168kB/s  
Complete output from command python setup.py egg\_info:  
Traceback (most recent call last):  
File “”, line 1, in   
File “/tmp/pip-build-W6kZPY/python-apt/setup.py”, line 6, in   
from DistUtilsExtra.command import \*  
ImportError: No module named DistUtilsExtra.command

---

<div class="post-metadata">

**Author:** ![Colin\_Davis](https://avatars.discourse-cdn.com/v4/letter/c/ecb155/32.png) [@Colin\_Davis](https://forum.ansible.com/u/Colin_Davis)\
**Post date:** [March 9, 2016, 9:08pm UTC](https://forum.ansible.com/t/ansible-installation-using-pip-broken/20673/4 "2016-03-09T21:08:16Z")

</div>

I’ve run into this problem as well - It’s annoying 😕

When I run with system python, I can use apt/yum/etc, but when I use virtualenvs, there’s always complications with dist-only packages.  
I haven’t found any easy way to work around these.  
My solution has been to replace the apt/yum lines with shell calls instead, but I’d love a better way to do this.
