我正在编写一个lambda函数,只是为了从AWS RDS表中获取一些数据。我能够成功运行sam package
和sam deploy
将该功能部署到AWS。
当我运行sam build
时,它会成功构建,然后运行sam local invoke
在本地测试lambda,但会收到以下错误输出
$ sam local invoke
Traceback (most recent call last):
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\docker\api\client.py", line 154, in __init__
self._custom_adapter = NpipeHTTPAdapter(
NameError: name 'NpipeHTTPAdapter' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\jthomas\AppData\Local\Programs\Python\Python38-32\Scripts\sam.exe\__main__.py", line 7, in <module>
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\click\decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\samcli\lib\telemetry\metrics.py", line 93, in wrapped
raise exception # pylint: disable=raising-bad-type
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\samcli\lib\telemetry\metrics.py", line 62, in wrapped
return_value = func(*args, **kwargs)
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\samcli\commands\local\invoke\cli.py", line 70, in cli
do_cli(
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\samcli\commands\local\invoke\cli.py", line 131, in do_cli
with InvokeContext(
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\samcli\commands\local\cli_common\invoke_context.py", line 134, in __enter__
self._container_manager = self._get_container_manager(self._docker_network, self._skip_pull_image)
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\samcli\commands\local\cli_common\invoke_context.py", line 373, in _get_container_manager
return ContainerManager(docker_network_id=docker_network, skip_pull_image=skip_pull_image)
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\samcli\local\docker\manager.py", line 34, in __init__
self.docker_client = docker_client or docker.from_env()
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\docker\client.py", line 84, in from_env
return cls(
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\docker\client.py", line 40, in __init__
self.api = APIClient(*args, **kwargs)
File "c:\users\jthomas\appdata\local\programs\python\python38-32\lib\site-packages\docker\api\client.py", line 158, in __init__
raise DockerException(
docker.errors.DockerException: Install pypiwin32 package to enable npipe:// support
我的版本:
$ python --version
Python 3.8.0
$ aws --version
aws-cli/1.16.286 Python/3.6.0 Windows/10 botocore/1.13.22
$ sam --version
SAM CLI, version 0.33.1
Pip列表显示我已安装pypiwin32(v223)
$ pip list
Package Version
------------------- ---------
arrow 0.15.4
attrs 19.3.0
aws-lambda-builders 0.6.0
aws-sam-cli 0.33.1
aws-sam-translator 1.15.1
binaryornot 0.4.4
boto3 1.10.22
botocore 1.13.22
certifi 2019.9.11
chardet 3.0.4
chevron 0.13.1
Click 7.0
cookiecutter 1.6.0
dateparser 0.7.2
docker 4.1.0
docutils 0.15.2
Flask 1.0.4
future 0.18.2
idna 2.8
itsdangerous 1.1.0
Jinja2 2.10.3
jinja2-time 0.2.0
jmespath 0.9.4
jsonschema 3.2.0
MarkupSafe 1.1.1
pip 19.3.1
poyo 0.5.0
pypiwin32 223
pyrsistent 0.15.5
python-dateutil 2.8.0
pytz 2019.3
pywin32 225
PyYAML 5.1.2
regex 2019.11.1
requests 2.22.0
s3transfer 0.2.1
serverlessrepo 0.1.9
setuptools 41.6.0
six 1.13.0
tomlkit 0.5.8
tzlocal 2.0.0
urllib3 1.25.7
websocket-client 0.56.0
Werkzeug 0.16.0
wheel 0.33.6
whichcraft 0.6.1
Docker Desktop也已安装并在我的机器上运行。我去过https://github.com/docker/compose/issues/4842,并尝试通过MSI安装aws-sam-cli,但是没有用。我已经重新安装了Python,AWS CLI,AWS SAM CLI和Docker。我不确定下一步要去哪里。
是否有使我的AWS Lambda函数在本地运行的修补程序?
答案 0 :(得分:1)
我最终需要卸载通过pip安装的sam-cli版本,并改用Windows MSI安装程序。显然,使用MSI是Windows必需的安装方法。然后使用“ sam.cmd”调用sam cli。