in Ask

AWX Installation: Failed to import the required Python library

During AWX installation (which is the equivalent of tower for managing Ansible using the graphical interface) I got stopped with the following error:

TASK [local_docker : Start the containers] **************************************************************************************************************************************************
task path: /root/tmp/awx/installer/roles/local_docker/tasks/compose.yml:39
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6)) on localhost.localdomain's Python /usr/bin/python. Please read module documentation and install in the appropriate location. If the required library is installed, but Ansible is using the wrong Python interpreter, please consult the documentation on ansible_python_interpreter, for example via `pip install docker` or `pip install docker-py` (Python 2.6). The error was: No module named docker"}

PLAY RECAP **********************************************************************************************************************************************************************************
localhost                  : ok=14   changed=2    unreachable=0    failed=1    skipped=95   rescued=0    ignored=0

If you try to install docker, you will end up with another error about dependency:

[root@localhost installer]# pip install docker

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting docker
  Using cached docker-4.2.0-py2.py3-none-any.whl (143 kB)
Requirement already satisfied: six>=1.4.0 in /usr/lib/python2.7/site-packages (from docker) (1.14.0)
Collecting requests!=2.18.0,>=2.14.2
  Using cached requests-2.23.0-py2.py3-none-any.whl (58 kB)
Requirement already satisfied: backports.ssl-match-hostname>=3.5; python_version < "3.5" in /usr/lib/python2.7/site-packages (from docker) (3.5.0.1)
Requirement already satisfied: ipaddress>=1.0.16; python_version < "3.3" in /usr/lib/python2.7/site-packages (from docker) (1.0.16)
Requirement already satisfied: websocket-client>=0.32.0 in /usr/lib/python2.7/site-packages (from docker) (0.56.0)
Requirement already satisfied: idna<3,>=2.5 in /usr/lib/python2.7/site-packages (from requests!=2.18.0,>=2.14.2->docker) (2.9)
Requirement already satisfied: chardet<4,>=3.0.2 in /usr/lib/python2.7/site-packages (from requests!=2.18.0,>=2.14.2->docker) (3.0.4)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/lib/python2.7/site-packages (from requests!=2.18.0,>=2.14.2->docker) (1.25.8)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python2.7/site-packages (from requests!=2.18.0,>=2.14.2->docker) (2019.11.28)
Installing collected packages: requests, docker
  Attempting uninstall: requests
    Found existing installation: requests 2.6.0
ERROR: Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

I was able to bypass this error by ignoring the already installed package, this is a Dev environement, it’s not a big deal, on production you should avoid doing it.

[root@localhost installer]# pip install --ignore-installed  docker

Share your thoughts

Comment