Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6))

software engineering Dec 27, 2019

I’ve been playing around with Docker and Ansible this break. I just hit a rather bizarre issue that kept cropping up. The error I got was “Failed to import the required Python library (Docker SDK for Python: docker (Python >= 2.7) or docker-py (Python 2.6))

I tried uninstalling Python 2 from the server and then reinstalling the various libraries when I found this article that solved the issue

The gist of the fix is as follows:

  1. Run pip list | egrep 'requests' to confirm if the requests library is still there
  2. Uninstall all the other libraries if they exist by running pip uninstall docker docker-py requests
  3. Confirm that the libraries are removed by running pip list | egrep 'docker|docker-py|requests'
  4. Re-install the libraries by running pip uninstall docker docker-py requests

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.