In order to use the Docker SDK for Python, I\'m trying to import docker
in a Python script, but it\'s resulting in an ImportError
with the following tr
Let me explain the root cause of the issue. python looks for 'backports' directory, when it is found, python looks for 'ssl_match_hostname' subdirectory. If it is not found, it is an error. In other words if one has '/usr/lib.../backports' and no '/usr/lib.../backports/ssl_match_hostname' (any backport installed by apt), it is pointless to use pip to install anything in /usr/local/lib or in /home.
If we have a collision between distro and pip:
dpkg-query -S /usr/lib/python2.7/dist-packages/backports
apt remove all_found_packages
pip install whatever_you_need
If we have a collision between global and local pip do similar trick.
It is handy to use strace to solve such issues.
I had backports.ssl-match-hostname
installed locally, which was preventing it from being installed at the system level. I solved it by
sudo pip uninstall backports.ssl-match-hostname
followed by
sudo pip install --upgrade docker