aws-sam-cli: Hello world fails to build on Windows 10
Description
Python version of hello-world fails to build on Windows 10
Steps to reproduce
I can reproduce it in 2 ways. First way to reproduce:
sam init --runtime=python3.6 cd sam-app sam build --use-container
Can also be reproduced if I do the following: Step 0: (if necessary to clean up from above steps, in WSL): cd …;rm -rf sam-app sam init --runtime=python3.6 cd sam-app sam build sam local start-api --debug
This seems to only happen on my machine, but I don’t know how to recover. I tried to reinstall Python, the AWS CLI, SAM CLI, docker, and I’m having no luck.
Observed result
PS C:\proj\sls\sam-app> sam local start-api --debug 2018-12-10 12:11:01 Using SAM Template at C:\proj\sls\sam-app.aws-sam\build\templat 2018-12-10 12:11:01 Changing event name from creating-client-class.iot-data to creat 2018-12-10 12:11:01 Changing event name from before-call.apigateway to before-call.a 2018-12-10 12:11:01 Changing event name from request-created.machinelearning.Predict .Predict 2018-12-10 12:11:01 Changing event name from before-parameter-build.autoscaling.Crea meter-build.auto-scaling.CreateLaunchConfiguration 2018-12-10 12:11:01 Changing event name from before-parameter-build.route53 to befor 2018-12-10 12:11:01 Changing event name from request-created.cloudsearchdomain.Searc ain.Search 2018-12-10 12:11:01 Changing event name from docs..autoscaling.CreateLaunchConfigur o-scaling.CreateLaunchConfiguration.complete-section 2018-12-10 12:11:01 Changing event name from before-parameter-build.logs.CreateExpor dwatch-logs.CreateExportTask 2018-12-10 12:11:01 Changing event name from docs..logs.CreateExportTask.complete-s ateExportTask.complete-section 2018-12-10 12:11:01 Changing event name from before-parameter-build.cloudsearchdomai loudsearch-domain.Search 2018-12-10 12:11:01 Changing event name from docs..cloudsearchdomain.Search.complet in.Search.complete-section 2018-12-10 12:11:01 Changing event name from creating-client-class.iot-data to creat 2018-12-10 12:11:01 Changing event name from before-call.apigateway to before-call.a 2018-12-10 12:11:01 Changing event name from request-created.machinelearning.Predict .Predict 2018-12-10 12:11:01 Changing event name from before-parameter-build.autoscaling.Crea meter-build.auto-scaling.CreateLaunchConfiguration 2018-12-10 12:11:01 Changing event name from before-parameter-build.route53 to befor 2018-12-10 12:11:01 Changing event name from request-created.cloudsearchdomain.Searc ain.Search 2018-12-10 12:11:01 Changing event name from docs..autoscaling.CreateLaunchConfigur o-scaling.CreateLaunchConfiguration.complete-section 2018-12-10 12:11:01 Changing event name from before-parameter-build.logs.CreateExpor dwatch-logs.CreateExportTask 2018-12-10 12:11:01 Changing event name from docs..logs.CreateExportTask.complete-s ateExportTask.complete-section 2018-12-10 12:11:01 Changing event name from before-parameter-build.cloudsearchdomai loudsearch-domain.Search 2018-12-10 12:11:01 Changing event name from docs..cloudsearchdomain.Search.complet in.Search.complete-section 2018-12-10 12:11:01 local start-api command is called 2018-12-10 12:11:01 Looking for credentials via: env 2018-12-10 12:11:01 Looking for credentials via: assume-role 2018-12-10 12:11:01 Looking for credentials via: shared-credentials-file 2018-12-10 12:11:01 Found credentials in shared credentials file: ~/.aws/credentials 2018-12-10 12:11:01 Loading JSON file: c:\program files\python36\lib\site-packages\b 2018-12-10 12:11:01 Event choose-service-name: calling handler <function handle_serv
2018-12-10 12:11:01 Loading JSON file: c:\program files\python36\lib\site-packages\b 08\service-2.json 2018-12-10 12:11:01 Event creating-client-class.serverlessapplicationrepository: cal presigned_url at 0x0000024E419F7A60> 2018-12-10 12:11:01 The s3 config key is not a dictionary type, ignoring its value o 2018-12-10 12:11:01 Setting serverlessrepo timeout as (60, 60) 2018-12-10 12:11:01 Loading JSON file: c:\program files\python36\lib\site-packages\b 2018-12-10 12:11:01 Registering retry handlers for service: serverlessrepo 2018-12-10 12:11:01 No Parameters detected in the template 2018-12-10 12:11:01 2 resources found in the template 2018-12-10 12:11:01 Found Serverless function with name=‘HelloWorldFunction’ and Cod 2018-12-10 12:11:01 Trying paths: [‘C:\Users\mkislik\.docker\config.json’, 'C:\ 2018-12-10 12:11:01 Found file at path: C:\Users\mkislik.docker\config.json 2018-12-10 12:11:01 Found ‘auths’ section 2018-12-10 12:11:01 Auth data for https://index.docker.io/v1/ is absent. Client migh ad. 2018-12-10 12:11:01 Found ‘credsStore’ section Traceback (most recent call last): File “c:\program files\python36\lib\site-packages\docker\api\client.py”, line 140, self._custom_adapter = NpipeAdapter( NameError: name ‘NpipeAdapter’ is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “c:\program files\python36\lib\runpy.py”, line 193, in _run_module_as_main
“main”, mod_spec)
File “c:\program files\python36\lib\runpy.py”, line 85, in run_code
exec(code, run_globals)
File "C:\Program Files\Python36\Scripts\sam.exe_main.py", line 9, in <module>
File “c:\program files\python36\lib\site-packages\click\core.py”, line 722, in __c
return self.main(*args, **kwargs)
File “c:\program files\python36\lib\site-packages\click\core.py”, line 697, in mai
rv = self.invoke(ctx)
File “c:\program files\python36\lib\site-packages\click\core.py”, line 1066, in in
return process_result(sub_ctx.command.invoke(sub_ctx))
File “c:\program files\python36\lib\site-packages\click\core.py”, line 1066, in in
return process_result(sub_ctx.command.invoke(sub_ctx))
File “c:\program files\python36\lib\site-packages\click\core.py”, line 895, in inv
return ctx.invoke(self.callback, **ctx.params)
File “c:\program files\python36\lib\site-packages\click\core.py”, line 535, in inv
return callback(*args, **kwargs)
File “c:\program files\python36\lib\site-packages\click\decorators.py”, line 64, i
return ctx.invoke(f, obj, *args[1:], **kwargs)
File “c:\program files\python36\lib\site-packages\click\core.py”, line 535, in inv
return callback(*args, **kwargs)
File "c:\program files\python36\lib\site-packages\samcli\commands\local\start_api
parameter_overrides) # pragma: no cover
File "c:\program files\python36\lib\site-packages\samcli\commands\local\start_api
aws_region=ctx.region) as invoke_context:
File "c:\program files\python36\lib\site-packages\samcli\commands\local\cli_common
enter
self._check_docker_connectivity()
File "c:\program files\python36\lib\site-packages\samcli\commands\local\cli_common
heck_docker_connectivity
docker_client = docker_client or docker.from_env()
File “c:\program files\python36\lib\site-packages\docker\client.py”, line 85, in f
timeout=timeout, version=version, **kwargs_from_env(**kwargs)
File “c:\program files\python36\lib\site-packages\docker\client.py”, line 40, in _
self.api = APIClient(*args, **kwargs)
File “c:\program files\python36\lib\site-packages\docker\api\client.py”, line 145,
‘Install pypiwin32 package to enable npipe:// support’
docker.errors.DockerException: Install pypiwin32 package to enable npipe:// support
Expected result
Running server I believe on port 3000, returning “hello world”.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS:
Windows 10
sam --version
:
SAM CLI, version 0.8.1
Add --debug flag to command you are running
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 26 (7 by maintainers)
So I installed sam-cli using msi and I was getting this issue. I tried everything in this thread and reinstalled everything, but the issue persisted nevertheless.
It turns out sam-cli is using a different python installation at runtime, and for me, it is located in
C:\Program Files\Amazon\AWSSAMCLI\runtime
This thing uses docker-4.0.4 which is outdated so I ran
./python -m pip install --upgrade docker
in the runtime folder, and after upgrading to docker-5.0.3 I am longer facing the issue.I don’t see the option to reopen this issue.
I remember working around the issue by: downgrading pypiwin32=220, but that was around 10 months ago. Others are saying downgrading pywin32 from version 225 to 224 worked for them.
I also asked AWS to document this problem and the solution, but that did not happen, either.
@mkislik Thanks! It looks like this issue was caused by an out-of-date version of the ‘docker’ pip package.
None of the following had any effect:
awscli
package:python -m pip install --upgrade awscli
aws-sam-cli
package:python -m pip install aws-sam-cli
But this fixed the issue:
docker
package from 3.4.0 to 3.7.0:python -m pip install --upgrade docker
I’m investigating the new error now, but it looks like an unrelated issue. Edit: Un-sharing and then re-sharing my C drive with Docker fixed the new issue.
So the question is: Why was my docker dependency out of date despite just installing SAM CLI 0.10 yesterday? Should the minimum version be updated in SAM CLI’s dependencies?