'ImportError: No module named ssl_match_hostname' upon 'import docker' in a Python script
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.7k
- Avg merge
- 13d 8h
- Merged PRs (30d)
- 2
Description
In a script ~/Documents/Scratch/test_import_docker.py with the single statement import docker, I'm getting the following ImportError:
Traceback (most recent call last):
File "test_import_docker.py", line 1, in <module>
import docker
File "/home/kurt/.local/lib/python2.7/site-packages/docker/__init__.py", line 6, in <module>
from .client import Client, AutoVersionClient, from_env # flake8: noqa
File "/home/kurt/.local/lib/python2.7/site-packages/docker/client.py", line 11, in <module>
from . import api
File "/home/kurt/.local/lib/python2.7/site-packages/docker/api/__init__.py", line 2, in <module>
from .build import BuildApiMixin
File "/home/kurt/.local/lib/python2.7/site-packages/docker/api/build.py", line 9, in <module>
from .. import utils
File "/home/kurt/.local/lib/python2.7/site-packages/docker/utils/__init__.py", line 2, in <module>
from .utils import (
File "/home/kurt/.local/lib/python2.7/site-packages/docker/utils/utils.py", line 19, in <module>
from .. import tls
File "/home/kurt/.local/lib/python2.7/site-packages/docker/tls.py", line 5, in <module>
from .ssladapter import ssladapter
File "/home/kurt/.local/lib/python2.7/site-packages/docker/ssladapter/__init__.py", line 1, in <module>
from .ssladapter import SSLAdapter # flake8: noqa
File "/home/kurt/.local/lib/python2.7/site-packages/docker/ssladapter/ssladapter.py", line 21, in <module>
from backports.ssl_match_hostname import match_hostname
ImportError: No module named ssl_match_hostname
Strangely, I am able to import docker from iPython:
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
Type "copyright", "credits" or "license" for more information.
IPython 2.4.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import docker
In [2]:
Why is the import not working in the first case?
My Docker version from the command line is:
kurt@kurt-ThinkPad:~$ docker --version
Docker version 1.12.3, build 6b644ec
whereas the version in Python is
In [3]: docker.version
Out[3]: '1.10.3'
Incidentally, I've also created a StackOverflow question about this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with test_import_docker.py using the same Python interpreter, then inspect docker/init.py and docker/ssladapter/ssladapter.py along with the reported package environments. Compare those imports with the working IPython session; done means the environment or dependency discrepancy is identified and the issue has a confirmed resolution or documented cause.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, python
- Domain
- api, developer-experience
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100