Aws-sam-cli: NameError: name 'NpipeHTTPAdapter' is not defined

Created on 24 Oct 2019  路  10Comments  路  Source: aws/aws-sam-cli

Getting this when running 'aws sam local start-api'

doesnt look like docker issues

pip 19.3.1
aws-sam-cli 0.22.0

Telemetry endpoint configured to be https://aws-serverless-tools-telemetry.us-west-2.amazonaws.com/metrics
local start-api command is called
Collected default values for parameters: {}
2 resources found in the template
Sending Telemetry: {'metrics': [{'commandRun': {'awsProfileProvided': False, 'debugFlagProvided': True, 'region': '', 'commandName': 'sam local start-api', 'duration': 37, 'exitReason': 'DockerException', 'exitCode': 255, 'requestId': '3c51c498-e9db-451d-bf4a-fd5240e5f305', 'installationId': '072d408a-950f-4a21-bb6b-cea85e65da65', 'sessionId': 'f271c9bb-1a19-41ea-aade-3b5fc99bac80', 'executionEnvironment': 'CLI', 'pyversion': '3.8.0', 'samcliVersion': '0.22.0'}}]}
HTTPSConnectionPool(host='aws-serverless-tools-telemetry.us-west-2.amazonaws.com', port=443): Read timed out. (read timeout=0.1)
Traceback (most recent call last):
  File "c:\program files\python38\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:\program files\python38\lib\runpy.py", line 192, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\program files\python38\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Program Files\Python38\Scripts\sam.exe\__main__.py", line 7, in <module>
  File "c:\program files\python38\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\program files\python38\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\program files\python38\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\program files\python38\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\program files\python38\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\program files\python38\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\program files\python38\lib\site-packages\click\decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "c:\program files\python38\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\program files\python38\lib\site-packages\samcli\lib\telemetry\metrics.py", line 93, in wrapped
    raise exception  # pylint: disable=raising-bad-type
  File "c:\program files\python38\lib\site-packages\samcli\lib\telemetry\metrics.py", line 62, in wrapped
    return_value = func(*args, **kwargs)
  File "c:\program files\python38\lib\site-packages\samcli\commands\local\start_api\cli.py", line 75, in cli
    do_cli(
  File "c:\program files\python38\lib\site-packages\samcli\commands\local\start_api\cli.py", line 123, in do_cli
    with InvokeContext(
  File "c:\program files\python38\lib\site-packages\samcli\commands\local\cli_common\invoke_context.py", line 141, in __enter__
    self._container_manager = self._get_container_manager(self._docker_network, self._skip_pull_image)
  File "c:\program files\python38\lib\site-packages\samcli\commands\local\cli_common\invoke_context.py", line 381, in _get_container_manager
    return ContainerManager(docker_network_id=docker_network, skip_pull_image=skip_pull_image)
  File "c:\program files\python38\lib\site-packages\samcli\local\docker\manager.py", line 34, in __init__
    self.docker_client = docker_client or docker.from_env()
  File "c:\program files\python38\lib\site-packages\docker\client.py", line 84, in from_env
    return cls(
  File "c:\program files\python38\lib\site-packages\docker\client.py", line 40, in __init__
    self.api = APIClient(*args, **kwargs)
  File "c:\program files\python38\lib\site-packages\docker\api\client.py", line 158, in __init__
    raise DockerException(
docker.errors.DockerException: Install pypiwin32 package to enable npipe:// support

Most helpful comment

pypiwin32 is a dependency of the docker-py library, for win32 only. Looking at docker-py: https://pypi.org/project/docker/ they don't yet claim support for python3.8, neither do we (yet). Given the last release of pypiwin32, https://pypi.org/project/pypiwin32/#history, not sure if that even supports py3.8 either.

Using the MSI for windows is the best path.

Resolving since the issue was resolved by using the MSI instead of pip.

All 10 comments

I think that the issue was caused by upgrading aws-sam-cli via pip
resolved by pip uninstalling aws-sam-cli
and installing it from .msi

pypiwin32 is a dependency of the docker-py library, for win32 only. Looking at docker-py: https://pypi.org/project/docker/ they don't yet claim support for python3.8, neither do we (yet). Given the last release of pypiwin32, https://pypi.org/project/pypiwin32/#history, not sure if that even supports py3.8 either.

Using the MSI for windows is the best path.

Resolving since the issue was resolved by using the MSI instead of pip.

@jfuss
Where do I get the MSI for pypiwin32? Google search is not turning anything up, and it's not at the URL you linked.

@carbonox-infernox That is the MSI for SAM CLI not pypiwin32.

The MSI is attached to SAM CLI release notes: https://github.com/awslabs/aws-sam-cli/releases/tag/v0.23.0

As @plantusd pointed out. The following step works for me. Uninstalling aws-sam-cli which was initially installed via pip. To uninstall use pip3 uninstall awscli command.
Then, install MSI version AWS SAM CLI. You can grab it here

Hello, @jfuss, @ermiaswalelgne I installed AWS SAM CLI using the MSI yesterday.
I have docker running but I still have this issue when running sam local invoke start-api or any other "local" command.

Since I never installed SAM using pip, I can't uninstall it:
pip3 uninstall awscli Skipping awscli as it is not installed.

My versions:
aws --version aws-cli/1.17.9 Python/3.6.0 Windows/10 botocore/1.14.9
sam --version SAM CLI, version 0.40.0
docker --version Docker version 19.03.5, build 633a0ea

I also have a python version lower than 3.8.
python --version Python 3.6.3

Do you know what could be the issue?
Thank you very much.

@lekimlarra sam issue. did you resolve it?

Had the same issue with both python 3.6 and 3.8, but using python==3.7 with pypiwin==223 resolved it

I'm having this same issue as well.

Upgrading from SAM CLI 1.7.0 to 1.8.0 fixed this error for me when hitting it in the AWS Toolkit in Pycharm.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

terlar picture terlar  路  3Comments

goldenbearkin picture goldenbearkin  路  3Comments

cvuijst picture cvuijst  路  3Comments

rhlsthrm picture rhlsthrm  路  4Comments

joekiller picture joekiller  路  4Comments