ImportError: No module named backports.ssl_match_hostname

Bug #1846712 reported by Hadmut Danisch
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
docker-compose (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

The error ImportError: No module named backports.ssl_match_hostname is back again. When running docker-compose, it terminates with the error message

% docker-compose
Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 11, in <module>
    load_entry_point('docker-compose==1.17.1', 'console_scripts', 'docker-compose')()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 480, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2693, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2324, in load
    return self.resolve()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 2330, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/dist-packages/compose/cli/main.py", line 17, in <module>
    from . import errors
  File "/usr/lib/python2.7/dist-packages/compose/cli/errors.py", line 11, in <module>
    from docker.errors import APIError
  File "/usr/lib/python2.7/dist-packages/docker/__init__.py", line 2, in <module>
    from .api import APIClient
  File "/usr/lib/python2.7/dist-packages/docker/api/__init__.py", line 2, in <module>
    from .client import APIClient
  File "/usr/lib/python2.7/dist-packages/docker/api/client.py", line 11, in <module>
    from .build import BuildApiMixin
  File "/usr/lib/python2.7/dist-packages/docker/api/build.py", line 9, in <module>
    from .. import utils
  File "/usr/lib/python2.7/dist-packages/docker/utils/__init__.py", line 2, in <module>
    from .build import tar, exclude_paths
  File "/usr/lib/python2.7/dist-packages/docker/utils/build.py", line 5, in <module>
    from .utils import create_archive
  File "/usr/lib/python2.7/dist-packages/docker/utils/utils.py", line 18, in <module>
    from .. import tls
  File "/usr/lib/python2.7/dist-packages/docker/tls.py", line 5, in <module>
    from .transport import SSLAdapter
  File "/usr/lib/python2.7/dist-packages/docker/transport/__init__.py", line 3, in <module>
    from .ssladapter import SSLAdapter
  File "/usr/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 backports.ssl_match_hostname

Probable reason: On my system (ubuntu 18.04) docker.io is

Package: docker.io
Version: 18.09.7-0ubuntu1~18.04.4

but docker-compose is

Package: docker-compose
Version: 1.17.1-2

Loading a newer docker-compose binary from the git repo (e.g. 1.24.0) solves the problem, but it's still a flaw if the ubuntu packages need to be fixed by replacing binaries with external files.

E.g. download with

sudo curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

ProblemType: Bug
DistroRelease: Ubuntu 18.04
Package: docker-compose 1.17.1-2
ProcVersionSignature: Ubuntu 4.15.0-60.67-generic 4.15.18
Uname: Linux 4.15.0-60-generic x86_64
NonfreeKernelModules: zfs zunicode zavl icp zcommon znvpair
ApportVersion: 2.20.9-0ubuntu7.7
Architecture: amd64
CurrentDesktop: XFCE
Date: Fri Oct 4 12:36:47 2019
InstallationDate: Installed on 2018-06-09 (481 days ago)
InstallationMedia: Lubuntu 18.04 LTS "Bionic Beaver" - Release amd64 (20180426)
PackageArchitecture: all
SourcePackage: docker-compose
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Hadmut Danisch (hadmut) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in docker-compose (Ubuntu):
status: New → Confirmed
Revision history for this message
Digulla-hepe (digulla-hepe) wrote :

Test cases:

    python2 -c "import backports.ssl_match_hostname"
    docker-compose --version

Fix / workaround (as root):

    echo "# package" > /usr/lib/python2.7/dist-packages/backports/__init__.py

Note: I'm not sure whether sudo will work with output redirection.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.