# Failed to import docker or docker-py - cannot import name constants” when installing AWX on Ubuntu 19.04

**URL:** <https://forum.ansible.com/t/failed-to-import-docker-or-docker-py-cannot-import-name-constants-when-installing-awx-on-ubuntu-19-04/31219>\
**Category:** AWX Project\
**Tags:** ubuntu, awx\
**Created:** [September 6, 2019, 10:52pm UTC](https://forum.ansible.com/t/failed-to-import-docker-or-docker-py-cannot-import-name-constants-when-installing-awx-on-ubuntu-19-04/31219 "2019-09-06T22:52:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Moussa\_Balla](https://avatars.discourse-cdn.com/v4/letter/m/90ced4/32.png) [@Moussa\_Balla](https://forum.ansible.com/u/Moussa_Balla)\
**Post date:** [September 6, 2019, 10:52pm UTC](https://forum.ansible.com/t/failed-to-import-docker-or-docker-py-cannot-import-name-constants-when-installing-awx-on-ubuntu-19-04/31219/1 "2019-09-06T22:52:54Z")

</div>

TASK [local\_docker : Start the containers] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* fatal: [localhost]: FAILED! =\> {“changed”: false, “msg”: “Failed to import docker or docker-py - cannot import name constants. Try `pip install docker` or `pip install docker-py` (Python 2.6)”} to retry, use: --limit @/home/user/awx/installer/install.retry

---

<div class="post-metadata">

**Author:** ![Juan\_A\_S](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@Juan\_A\_S](https://forum.ansible.com/u/Juan_A_S)\
**Post date:** [September 7, 2019, 8:22am UTC](https://forum.ansible.com/t/failed-to-import-docker-or-docker-py-cannot-import-name-constants-when-installing-awx-on-ubuntu-19-04/31219/2 "2019-09-07T08:22:12Z")

</div>

Just do what the error says:

pip install docker-py

---

<div class="post-metadata">

**Author:** ![alancivita](https://avatars.discourse-cdn.com/v4/letter/a/b5a626/32.png) [@alancivita](https://forum.ansible.com/u/alancivita)\
**Post date:** [September 9, 2019, 8:08am UTC](https://forum.ansible.com/t/failed-to-import-docker-or-docker-py-cannot-import-name-constants-when-installing-awx-on-ubuntu-19-04/31219/3 "2019-09-09T08:08:25Z")

</div>

I had the same issue and this is what i’ve done - i’ve used a Centos box but it doesn’t matter

yum remove docker-compose (aot get remove docker-compose)  
yum remove ansible (apt get remove ansible)  
pip unisntall docker-py  
pip uninstall docker  
pip uninstall docker-py  
pip install ansible  
pip install docker  
pip install docker-compose

This should fix your dependancy errors

---

<div class="post-metadata">

**Author:** ![Michael\_McPherson](https://avatars.discourse-cdn.com/v4/letter/m/9de0a6/32.png) [@Michael\_McPherson](https://forum.ansible.com/u/Michael_McPherson)\
**Post date:** [February 19, 2020, 5:22pm UTC](https://forum.ansible.com/t/failed-to-import-docker-or-docker-py-cannot-import-name-constants-when-installing-awx-on-ubuntu-19-04/31219/4 "2020-02-19T17:22:04Z")

</div>

The solution to this issue is to make a change in the inventory file in awx/installer, the line is at the top. Change the interpreter.

#localhost ansible\_connection=local ansible\_python\_interpreter=“/usr/bin/env python”  
localhost ansible\_connection=local ansible\_python\_interpreter=“/usr/bin/env python3”

---

<div class="post-metadata">

**Author:** ![Blacksensei](https://avatars.discourse-cdn.com/v4/letter/b/b5ac83/32.png) [@Blacksensei](https://forum.ansible.com/u/Blacksensei)\
**Post date:** [February 22, 2020, 4:52pm UTC](https://forum.ansible.com/t/failed-to-import-docker-or-docker-py-cannot-import-name-constants-when-installing-awx-on-ubuntu-19-04/31219/5 "2020-02-22T16:52:39Z")

</div>

I hope this is not too late. I am actually new to AWX and I put a note on my blog about how I got it installed on ubuntu bionic. If it’s still relevant, kindly have a look at [http://www.mycodingpains.com/getting-started-with-ansible-works-awx/](http://www.mycodingpains.com/getting-started-with-ansible-works-awx/)
