Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker-compose gives error "ImportError: No module named ssl_match_hostname" when run as normal user

I've installed docker-compose with 'pip2.7 install docker-compose" but when I try to run it as 'normal' user I get the following error message:

mike@hugin:~/Tobedeleted$ docker-compose  -v
Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 7, in <module>
    from compose.cli.main import main
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/main.py", line 17, in <module>
    from . import errors
  File "/usr/local/lib/python2.7/dist-packages/compose/cli/errors.py", line 10, in <module>
    from docker.errors import APIError
  File "/usr/local/lib/python2.7/dist-packages/docker/__init__.py", line 2, in <module>
    from .api import APIClient
  File "/usr/local/lib/python2.7/dist-packages/docker/api/__init__.py", line 2, in <module>
    from .client import APIClient
  File "/usr/local/lib/python2.7/dist-packages/docker/api/client.py", line 11, in <module>
    from .build import BuildApiMixin
  File "/usr/local/lib/python2.7/dist-packages/docker/api/build.py", line 9, in <module>
    from .. import utils
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/__init__.py", line 2, in <module>
    from .build import tar, exclude_paths
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/build.py", line 4, in <module>
    from .utils import create_archive
  File "/usr/local/lib/python2.7/dist-packages/docker/utils/utils.py", line 18, in <module>
    from .. import tls
  File "/usr/local/lib/python2.7/dist-packages/docker/tls.py", line 5, in <module>
    from .transport import SSLAdapter
  File "/usr/local/lib/python2.7/dist-packages/docker/transport/__init__.py", line 3, in <module>
    from .ssladapter import SSLAdapter
  File "/usr/local/lib/python2.7/dist-packages/docker/transport/ssladapter.py", line 21, in <module>
    from backports.ssl_match_hostname import match_hostname
ImportError: No module named ssl_match_hostname

This user is part of the docker group and can run 'docker ps' etc without any issue.

If I try to run 'sudo docker-compose -v' I get the same error.

However, if I run 'sudo su -' first and then issue 'docker-compose -v' I get the expected output.

root@hugin:~# docker-compose -v
docker-compose version 1.11.2, build dfed245

I've tried 'pip uninstall' for various, and all, parts of docker-compose, ssl_match_hostname and then reinstall but nothing seems to resolve it.

I'm now thoroughly stuck - any ideas out there?

like image 582
Swedish Mike Avatar asked Mar 31 '17 18:03

Swedish Mike


3 Answers

you have to reinstall docker-compose using this command:

curl -L https://github.com/docker/compose/releases/download/1.13.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

it worked for me

like image 200
user692727 Avatar answered Sep 28 '22 00:09

user692727


you should check if docker-compose exist, is installed and running:

$ whereis docker-compose
$ docker-compose --version

check if exist symbolic link pip -> pip2.7 or pip -> pip3.6 by running:

$ sudo pip install docker-compose
like image 31
TOR Avatar answered Sep 28 '22 00:09

TOR


This happened to me after updating to Python 3.10. I fixed it by reinstalling docker-compose with:

pip install docker-compose

Note: running yay -S docker-compose on Manjaro didn't work for me.

like image 35
Gabriel Ziegler Avatar answered Sep 28 '22 00:09

Gabriel Ziegler