`sam local invoke`error 'NameError: name 'NpipeHTTPAdapter' is not defined'
`sam local invoke`error 'NameError: name 'NpipeHTTPAdapter' is not defined'
我正在编写一个 lambda 函数只是为了从 AWS RDS table 获取一些数据。我能够成功 运行 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 也安装在我的机器上 运行ning。我一直在 https://github.com/docker/compose/issues/4842 并尝试通过 MSI 安装 aws-sam-cli 但没有成功。我已重新安装 Python、AWS CLI、AWS SAM CLI 和 Docker。我不知道下一步该去哪里。
是否有任何修复程序可以在本地获取我的 AWS Lambda 函数 运行ning?
我最终需要卸载通过 pip 安装的 sam-cli 版本并改用 Windows MSI 安装程序。显然使用 MSI 是 Windows 所需的安装方法。然后使用 'sam.cmd' 调用 sam cli。
我正在编写一个 lambda 函数只是为了从 AWS RDS table 获取一些数据。我能够成功 运行 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 也安装在我的机器上 运行ning。我一直在 https://github.com/docker/compose/issues/4842 并尝试通过 MSI 安装 aws-sam-cli 但没有成功。我已重新安装 Python、AWS CLI、AWS SAM CLI 和 Docker。我不知道下一步该去哪里。
是否有任何修复程序可以在本地获取我的 AWS Lambda 函数 运行ning?
我最终需要卸载通过 pip 安装的 sam-cli 版本并改用 Windows MSI 安装程序。显然使用 MSI 是 Windows 所需的安装方法。然后使用 'sam.cmd' 调用 sam cli。