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
If you're seeing this from docker-compose:
For me the answer by @CGFoX didn't work, even though this was in the correct direction. When analyzing the issue, we figured that there were two python paths for dist-packages, /usr/local/lib/python2.7/dist-packages/backports
and /usr/lib/python2.7/dist-packages/backports
.
Python was trying to load the module 'ssl_match_hostname' module from /usr/local/lib/python2.7/dist-packages/backports. But it was not present there:
drwxr-sr-x 5 root staff 4096 Aug 12 07:46 ./
drwxrwsr-x 130 root staff 12288 Aug 12 07:37 ../
-rw-r--r-- 1 root staff 75 Nov 14 2018 __init__.py
-rw-r--r-- 1 root staff 269 Nov 14 2018 __init__.pyc
drwxr-sr-x 2 root staff 4096 Nov 14 2018 configparser/
drwxr-sr-x 2 root staff 4096 Nov 14 2018 shutil_get_terminal_size/
But the module is present in the other location.
x@soumubuntu:~$ ll /usr/lib/python2.7/dist-packages/backports
total 16
drwxr-xr-x 3 root root 4096 Aug 12 07:19 ./
drwxr-xr-x 78 root root 4096 Aug 12 06:51 ../
-rw-r--r-- 1 root root 0 Aug 9 03:05 __init__.py
-rw-r--r-- 1 root root 141 Aug 12 07:19 __init__.pyc
drwxr-xr-x 2 root root 4096 Aug 12 07:19 ssl_match_hostname/
So, I copied it from B->A:
sudo cp -r /usr/lib/python2.7/dist-packages/backports/ssl_match_hostname/ /usr/local/lib/python2.7/dist-packages/backports/
and voila, docker compose is working now.