aws-sam-cli icon indicating copy to clipboard operation
aws-sam-cli copied to clipboard

ImportError: No module named ssl_match_hostname

Open bjorntheart opened this issue 8 years ago • 9 comments

Description:

I am trying to run sam local start-api and get the following import error

ImportError: No module named ssl_match_hostname

Observed result:

2018-05-22 12:59:26 Command 'local' is not configured correctly. Unable to import 'samcli.commands.local.local'
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/samcli/cli/command.py", line 100, in get_command
    mod = importlib.import_module(pkg_name)
  File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/site-packages/samcli/commands/local/local.py", line 8, in <module>
    from .invoke.cli import cli as invoke_cli
  File "/usr/local/lib/python2.7/site-packages/samcli/commands/local/invoke/cli.py", line 11, in <module>
    from samcli.commands.local.cli_common.invoke_context import InvokeContext
  File "/usr/local/lib/python2.7/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 9, in <module>
    import docker
  File "/Users/bjorn/Library/Python/2.7/lib/python/site-packages/docker/__init__.py", line 2, in <module>
    from .api import APIClient
  File "/Users/bjorn/Library/Python/2.7/lib/python/site-packages/docker/api/__init__.py", line 2, in <module>
    from .client import APIClient
  File "/Users/bjorn/Library/Python/2.7/lib/python/site-packages/docker/api/client.py", line 10, in <module>
    from .build import BuildApiMixin
  File "/Users/bjorn/Library/Python/2.7/lib/python/site-packages/docker/api/build.py", line 6, in <module>
    from .. import auth
  File "/Users/bjorn/Library/Python/2.7/lib/python/site-packages/docker/auth.py", line 9, in <module>
    from .utils import config
  File "/Users/bjorn/Library/Python/2.7/lib/python/site-packages/docker/utils/__init__.py", line 3, in <module>
    from .decorators import check_resource, minimum_version, update_headers
  File "/Users/bjorn/Library/Python/2.7/lib/python/site-packages/docker/utils/decorators.py", line 4, in <module>
    from . import utils
  File "/Users/bjorn/Library/Python/2.7/lib/python/site-packages/docker/utils/utils.py", line 12, in <module>
    from .. import tls
  File "/Users/bjorn/Library/Python/2.7/lib/python/site-packages/docker/tls.py", line 5, in <module>
    from .transport import SSLAdapter
  File "/Users/bjorn/Library/Python/2.7/lib/python/site-packages/docker/transport/__init__.py", line 3, in <module>
    from .ssladapter import SSLAdapter
  File "/Users/bjorn/Library/Python/2.7/lib/python/site-packages/docker/transport/ssladapter.py", line 21, in <module>
    from backports.ssl_match_hostname import match_hostname
ImportError: No module named ssl_match_hostname
Usage: sam [OPTIONS] COMMAND [ARGS]...

Error: No such command "local".

Expected result:

start local api

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

ProductName:	Mac OS X
ProductVersion:	10.12.6
BuildVersion:	16G29

Output of sam --version:

SAM CLI, version 0.3.0

bjorntheart avatar May 22 '18 11:05 bjorntheart

If you are using the default Python installation coming from Mac, this is a problem. Can you brew install python@2 and try again? Checkout the instructions here https://github.com/awslabs/aws-sam-cli#mac-issues

sanathkr avatar May 22 '18 17:05 sanathkr

Closing for now, but please feel free to reopen if this is still an issue.

sanathkr avatar May 22 '18 17:05 sanathkr

@bjorntheart I encountered this too. Uninstalling backports.ssl-match-hostname and then updating docker again fixed the issue:

pip uninstall backports.ssl-match-hostname
pip install -U docker

See: https://stackoverflow.com/questions/42695004/importerror-no-module-named-ssl-match-hostname-when-importing-the-docker-sdk-fo

brysontyrrell avatar May 22 '18 18:05 brysontyrrell

@sanathkr I did try that, but it didn't work for me. @brysontyrrell Worked like a charm.

Thanks to the both of you for the quick responses 👍

bjorntheart avatar May 23 '18 07:05 bjorntheart

I ran into this too, @brysontyrrell's fix worked for me.

mwarkentin avatar May 23 '18 12:05 mwarkentin

@brysontyrrell fantastic, it works for me

hubert-fan-rft avatar Jun 14 '18 02:06 hubert-fan-rft

@brysontyrrell this worked for me as well

Suggest putting this under https://github.com/awslabs/aws-sam-cli#troubleshooting as it seems to be an ongoing issue

mntlty avatar Jul 31 '18 20:07 mntlty

Thanks. To resolve above issue on Ubuntu 18.10, the second answer here worked for me.. https://stackoverflow.com/a/51071841

harprit avatar Dec 16 '18 08:12 harprit

I encountered this while using aws sam cli on Cloud9. Then, I reinstalled aws-sam-cli using brew tap aws/tap and brew install aws-sam-cli and it worked for me. For more information, you can refer to this article.

Jun711 avatar Aug 11 '19 06:08 Jun711