question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Command 'local' is not configured correctly. Unable to import 'samcli.commands.local.local'

See original GitHub issue

Description:

After installing v0.3.0, none of the commands work anymore and there is a configuration error shown

Steps to reproduce the issue:

  1. Uninstalled npm version
  2. pip install --user aws-sam-cli
  3. sam

Observed result:

~/Work/project (master): sam
2018-05-08 17:43:58 Command 'local' is not configured correctly. Unable to import 'samcli.commands.local.local'
Traceback (most recent call last):
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/cli/command.py", line 100, in get_command
    mod = importlib.import_module(pkg_name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/commands/local/local.py", line 8, in <module>
    from .invoke.cli import cli as invoke_cli
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/commands/local/invoke/cli.py", line 11, in <module>
    from samcli.commands.local.cli_common.invoke_context import InvokeContext
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 18, in <module>
    from ..lib.sam_function_provider import SamFunctionProvider
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/commands/local/lib/sam_function_provider.py", line 9, in <module>
    from .sam_base_provider import SamBaseProvider
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/commands/local/lib/sam_base_provider.py", line 5, in <module>
    from samcli.lib.samlib.wrapper import SamTranslatorWrapper
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/lib/samlib/wrapper.py", line 18, in <module>
    from samtranslator.validator.validator import SamTemplateValidator
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samtranslator/validator/validator.py", line 4, in <module>
    import sam_schema
ModuleNotFoundError: No module named 'sam_schema'
2018-05-08 17:43:58 Command 'validate' is not configured correctly. Unable to import 'samcli.commands.validate.validate'
Traceback (most recent call last):
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/cli/command.py", line 100, in get_command
    mod = importlib.import_module(pkg_name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/commands/validate/validate.py", line 16, in <module>
    from .lib.sam_template_validator import SamTemplateValidator
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/commands/validate/lib/sam_template_validator.py", line 5, in <module>
    from samtranslator.parser.parser import Parser
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samtranslator/parser/parser.py", line 2, in <module>
    from samtranslator.validator.validator import SamTemplateValidator
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samtranslator/validator/validator.py", line 4, in <module>
    import sam_schema
ModuleNotFoundError: No module named 'sam_schema'
Usage: sam [OPTIONS] COMMAND [ARGS]...

  AWS Serverless Application Model (SAM) CLI

  The AWS Serverless Application Model extends AWS CloudFormation to provide
  a simplified way of defining the Amazon API Gateway APIs, AWS Lambda
  functions, and Amazon DynamoDB tables needed by your serverless
  application. You can find more in-depth guide about the SAM specification
  here: https://github.com/awslabs/serverless-application-model.

Options:
  --debug    Turn on debug logging
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  package  Package an AWS SAM application. This is an alias for 'aws
           cloudformation package'.
  init     Initialize a serverless application with a...
  deploy   Deploy an AWS SAM application. This is an alias for 'aws
           cloudformation deploy'.

Expected result:

I expect the commands to work as expected. Displaying help should simply show:

Usage: sam [OPTIONS] COMMAND [ARGS]...

  AWS Serverless Application Model (SAM) CLI

  The AWS Serverless Application Model extends AWS CloudFormation to provide
  a simplified way of defining the Amazon API Gateway APIs, AWS Lambda
  functions, and Amazon DynamoDB tables needed by your serverless
  application. You can find more in-depth guide about the SAM specification
  here: https://github.com/awslabs/serverless-application-model.

Options:
  --debug    Turn on debug logging
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  package  Package an AWS SAM application. This is an alias for 'aws
           cloudformation package'.
  init     Initialize a serverless application with a...
  deploy   Deploy an AWS SAM application. This is an alias for 'aws
           cloudformation deploy'.

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

macOS High Sierra 10.13.2 MBP 2017 2.8 GHz Intel Core i& 16 GB of RAM

Output of sam --version:

~: sam --version
SAM CLI, version 0.3.0

Optional Debug logs:

Add --debug flag to command you are running

$ sam local invoke project --debug

2018-05-08 17:49:09 Command 'local' is not configured correctly. Unable to import 'samcli.commands.local.local'
Traceback (most recent call last):
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/cli/command.py", line 100, in get_command
    mod = importlib.import_module(pkg_name)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/commands/local/local.py", line 8, in <module>
    from .invoke.cli import cli as invoke_cli
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/commands/local/invoke/cli.py", line 11, in <module>
    from samcli.commands.local.cli_common.invoke_context import InvokeContext
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 18, in <module>
    from ..lib.sam_function_provider import SamFunctionProvider
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/commands/local/lib/sam_function_provider.py", line 9, in <module>
    from .sam_base_provider import SamBaseProvider
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/commands/local/lib/sam_base_provider.py", line 5, in <module>
    from samcli.lib.samlib.wrapper import SamTranslatorWrapper
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samcli/lib/samlib/wrapper.py", line 18, in <module>
    from samtranslator.validator.validator import SamTemplateValidator
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/samtranslator/validator/validator.py", line 4, in <module>
    import sam_schema
ModuleNotFoundError: No module named 'sam_schema'
Usage: sam [OPTIONS] COMMAND [ARGS]...

Error: No such command "local".

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
LewScommented, Oct 14, 2018

Looks like this issue is back. Getting Command ‘local’ is not configured correctly. Unable to import ‘samcli.commands.local.local’ with the usual trace ending … ImportError: No module named ssl_match_hostname pip uninstall backports.ssl-match-hostname pip install -U docker Did not fix, nor did updating packages, awscli aws-sam-cli & backports.ssl-match-hostname Clearly a problem with the backports.ssl-match-hostname. Local version is backports.ssl-match-hostname-3.5.0.1 Current work around is to change default python to 3.6 where backports.ssl-match-hostname is not needed.

4reactions
ndelvallecommented, Aug 7, 2018

Thanks, @jfuss doing:

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

As posted here made it work 🙌🏻

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command 'local' is not configured correctly. Unable to import ...
I expect the commands to work as expected. Displaying help should simply show: Usage: sam [OPTIONS] COMMAND [ARGS]... AWS Serverless Application ...
Read more >
AWS SAM CLI configuration file
The AWS SAM CLI supports a project-level configuration file that stores ... For example, for the sam local start-api command, the configuration table...
Read more >
Steps to update AWS Cloud9 IDE SAM CLI to Latest Version
Command 'local' is not configured correctly. Unable to import 'samcli.commands.local.local'. Unable to invoke a global environment variable.
Read more >
Why does AWS SAM CLI 1.33.0 crash with _regex.cpython-38 ...
Today I updated to AWS SAM CLI version 1.33.0. Then it started crashing making issues during the deployment. When I run the command...
Read more >
Set up a local serverless environment using the AWS SAM CLI
Navigate to the directory under which you would like to create the serverless application and run the following command. sam init –runtime ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found