Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting TypeError: load_config() got an unexpected keyword argument 'config_dict' when trying to run sam local start-api #536

Closed
eranation opened this issue Jul 5, 2018 · 9 comments

Comments

@eranation
Copy link

Description:

This is probably a docker version issue, but when trying out the example, I'm getting this error: TypeError: load_config() got an unexpected keyword argument 'config_dict'

Steps to reproduce the issue:

  1. install sam cli via pip install --user aws-sam-cli
  2. follow the hello world tutorial
  3. sam local start-api

Observed result:

Error is printed (See below)

Expected result:

No errors

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

Mac. Sierra, 10.12.6
Python 2.7.10
pip 10.0.1 from /Library/Python/2.7/site-packages/pip (python 2.7)
Docker version 17.12.0-ce, build c97c6d6

Output of sam --version:

SAM CLI, version 0.4.0

Optional Debug logs:

Add --debug flag to command you are running

This probably explains the root cause, I assume the docker config structure changed or something?

sam local start-api --debug
2018-07-05 14:22:46 local start-api command is called
2018-07-05 14:22:46 2 resources found in the template
2018-07-05 14:22:46 Found Serverless function with name='HelloWorldFunction' and CodeUri='hello_world/'
2018-07-05 14:22:46 Trying paths: ['/Users/****/.docker/config.json', '/Users/****/.dockercfg']
2018-07-05 14:22:46 Found file at path: /Users/****/.docker/config.json
Traceback (most recent call last):
  File "/Users/****/Library/Python/2.7/bin/sam", line 11, in <module>
    sys.exit(cli())
  File "/Library/Python/2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Library/Python/2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Python/2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Python/2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Python/2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Library/Python/2.7/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/Library/Python/2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/****/Library/Python/2.7/lib/python/site-packages/samcli/commands/local/start_api/cli.py", line 56, in cli
    docker_network, log_file, skip_pull_image, profile)  # pragma: no cover
  File "/Users/****/Library/Python/2.7/lib/python/site-packages/samcli/commands/local/start_api/cli.py", line 80, in do_cli
    aws_profile=profile) as invoke_context:
  File "/Users/****/Library/Python/2.7/lib/python/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 93, in __enter__
    self._check_docker_connectivity()
  File "/Users/****/Library/Python/2.7/lib/python/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 284, in _check_docker_connectivity
    docker_client = docker_client or docker.from_env()
  File "/Users/****/Library/Python/2.7/lib/python/site-packages/docker/client.py", line 85, in from_env
    timeout=timeout, version=version, **kwargs_from_env(**kwargs)
  File "/Users/****/Library/Python/2.7/lib/python/site-packages/docker/client.py", line 40, in __init__
    self.api = APIClient(*args, **kwargs)
  File "/Users/****/Library/Python/2.7/lib/python/site-packages/docker/api/client.py", line 113, in __init__
    config_dict=self._general_configs
TypeError: load_config() got an unexpected keyword argument 'config_dict'
@johncblandii
Copy link
Contributor

Same here.

All commands ran:

~/Work/sandbox: sam init
[+] Initializing project structure...
[SUCCESS] - Read sam-app/README.md for further instructions on how to proceed
[*] Project initialization is now complete

~/Work/sandbox: cd sam-app/

~/Work/sandbox/sam-app: sam local start-api
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/bin/sam", line 11, in <module>
    sys.exit(cli())
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/samcli/commands/local/start_api/cli.py", line 56, in cli
    docker_network, log_file, skip_pull_image, profile)  # pragma: no cover
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/samcli/commands/local/start_api/cli.py", line 80, in do_cli
    aws_profile=profile) as invoke_context:
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 93, in __enter__
    self._check_docker_connectivity()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 284, in _check_docker_connectivity
    docker_client = docker_client or docker.from_env()
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/docker/client.py", line 81, in from_env
    **kwargs_from_env(**kwargs))
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/docker/client.py", line 38, in __init__
    self.api = APIClient(*args, **kwargs)
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/docker/api/client.py", line 110, in __init__
    config_dict=self._general_configs
TypeError: load_config() got an unexpected keyword argument 'config_dict'

~/Work/sandbox/sam-app: cat template.yaml 
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
    sam-app

    Sample SAM Template for sam-app
    
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
    Function:
        Timeout: 3


Resources:

    HelloWorldFunction:
        Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
        Properties:
            CodeUri: hello_world/
            Handler: app.lambda_handler
            Runtime: nodejs8.10
            Environment: # More info about Env Vars: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#environment-object
                Variables:
                    PARAM1: VALUE
            Events:
                HelloWorld:
                    Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
                    Properties:
                        Path: /hello
                        Method: get

Outputs:

    HelloWorldApi:
      Description: "API Gateway endpoint URL for Prod stage for Hello World function"
      Value: !Sub "https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/"

    HelloWorldFunction:
      Description: "Hello World Lambda Function ARN"
      Value: !GetAtt HelloWorldFunction.Arn

    HelloWorldFunctionIamRole:
      Description: "Implicit IAM Role created for Hello World function"
      Value: !GetAtt HelloWorldFunctionRole.Arn

~/Work/sandbox/sam-app: echo '{}' | sam local invoke HelloWorldFunction
2018-07-05 15:26:03 Reading invoke payload from stdin (you can also pass it from file with --event)
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/bin/sam", line 11, in <module>
    sys.exit(cli())
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args[1:], **kwargs)
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/samcli/commands/local/invoke/cli.py", line 44, in cli
    docker_network, log_file, skip_pull_image, profile)  # pragma: no cover
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/samcli/commands/local/invoke/cli.py", line 70, in do_cli
    aws_profile=profile) as context:
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 93, in __enter__
    self._check_docker_connectivity()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/samcli/commands/local/cli_common/invoke_context.py", line 284, in _check_docker_connectivity
    docker_client = docker_client or docker.from_env()
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/docker/client.py", line 81, in from_env
    **kwargs_from_env(**kwargs))
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/docker/client.py", line 38, in __init__
    self.api = APIClient(*args, **kwargs)
  File "/Users/john.bland/Library/Python/3.6/lib/python/site-packages/docker/api/client.py", line 110, in __init__
    config_dict=self._general_configs
TypeError: load_config() got an unexpected keyword argument 'config_dict'

@jfuss
Copy link
Contributor

jfuss commented Jul 5, 2018

@johncblandii and @eranation This is happening for inside the docker client when trying to load your docker config. Here is an issue on docker-py about this error.

Do either of you have docker and docker-py installed (a pip freeze would help in determining this)? The suggestion looks like you uninstall docker from the env. Can one of you try this?

@ianaya89
Copy link

ianaya89 commented Aug 16, 2018

I was having the same issue, I checked that I had installed docker and docker-py.
I run pip uninstall docker-py and that solved the issue.

Thanks @jfuss

@jfuss
Copy link
Contributor

jfuss commented Dec 27, 2018

Closing. This should no longer happen due to our installers we now have, as well.

@jfuss jfuss closed this as completed Dec 27, 2018
@sergeir72
Copy link

still happens

El Capitan, latest docker, latest sam cli

sam init
mvn clean package
sam local start-lambda

File "/usr/local/homebrew/lib/python2.7/site-packages/flask/app.py", line 976, in add_url_rule
rule = self.url_rule_class(rule, methods=methods, **options)
TypeError: init() got an unexpected keyword argument 'provide_automatic_options'

@jpascoe
Copy link

jpascoe commented Jul 13, 2019

Still happening (14th Jul 2019)

@jpascoe
Copy link

jpascoe commented Jul 13, 2019

I dont have docker-py installed

@nem035
Copy link

nem035 commented Aug 19, 2019

@jpascoe I had the same issue but after installing awscli and aws-sam-cli using python3, it worked for me:

pip3 install awscli aws-sam-cli

@jfuss
Copy link
Contributor

jfuss commented Aug 26, 2019

If this is still happening, it is because you are still using pip and are installing into a place that has a flask version that does not work with SAM CLI. Instead, uninstall the cli with pip and install using our installers (homebrew for mac and linux, msi for windows). Instructions/steps to install are here.

@aws aws locked as resolved and limited conversation to collaborators Aug 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants