Aws-sam-cli: ImportError: No module named ssl_match_hostname

Created on 22 May 2018  路  9Comments  路  Source: aws/aws-sam-cli

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

Most helpful comment

@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

All 9 comments

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

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

@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

@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 馃憤

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

@brysontyrrell fantastic, it works for me

@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

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

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GerbenRampaart picture GerbenRampaart  路  3Comments

asyba picture asyba  路  3Comments

zhangzhx picture zhangzhx  路  3Comments

terlar picture terlar  路  3Comments

jpbarto picture jpbarto  路  4Comments