Description:
Steps to reproduce the issue:
Upon executing sam package in windows. I ended up getting this error.
(python2) 位 sam package --debug
2018-05-15 06:15:23 package command is called
Traceback (most recent call last):
File "C:\Python27\Lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\Lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Users\TEUSER\Envs\python2\Scripts\sam.exe\__main__.py", line 9, in <module>
File "c:\users\teuser\envs\python2\lib\site-packages\click\core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "c:\users\teuser\envs\python2\lib\site-packages\click\core.py", line 697, in main
rv = self.invoke(ctx)
File "c:\users\teuser\envs\python2\lib\site-packages\click\core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "c:\users\teuser\envs\python2\lib\site-packages\click\core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\teuser\envs\python2\lib\site-packages\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "c:\users\teuser\envs\python2\lib\site-packages\click\decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "c:\users\teuser\envs\python2\lib\site-packages\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "c:\users\teuser\envs\python2\lib\site-packages\samcli\commands\package\__init__.py", line 22, in cli
do_cli(args) # pragma: no cover
File "c:\users\teuser\envs\python2\lib\site-packages\samcli\commands\package\__init__.py", line 26, in do_cli
execute_command("package", args)
File "c:\users\teuser\envs\python2\lib\site-packages\samcli\lib\samlib\cloudformation_command.py", line 17, in execute_command
subprocess.check_call([aws_cmd, 'cloudformation', command] + list(args))
File "C:\Python27\Lib\subprocess.py", line 181, in check_call
retcode = call(*popenargs, **kwargs)
File "C:\Python27\Lib\subprocess.py", line 168, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\Lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Python27\Lib\subprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
hey @kyeljmd, whenever you can, mind sharing the following as I don't have a Windows machine handy in here?
C:\Users\TEUSER\Envs\python2\Scripts\aws help aws.cmd helpaws.cmd fails you can either install system wide or inside your Virtualenv run `pip install awsclisam package will execute aws CLI under the hood and if it can't find it'll fail which seems to be the case here - If that is confirmed, we should definitely improve the error messaging there.
An unrelated minor note though:
--user flag as VirtualEnv is self-contained already and this should work pip install aws-sam-cliI'm getting the same error while running
sam package --template-file template.yaml --s3-bucket c21-peter-testing --output-template-file packaged.yaml
Traceback (most recent call last):
File "C:\Python27\Scripts\sam-script.py", line 11, in <module>
load_entry_point('aws-sam-cli==0.4.0', 'console_scripts', 'sam')()
File "C:\Python27\lib\site-packages\click\core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "C:\Python27\lib\site-packages\click\core.py", line 697, in main
rv = self.invoke(ctx)
File "C:\Python27\lib\site-packages\click\core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Python27\lib\site-packages\click\core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Python27\lib\site-packages\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "C:\Python27\lib\site-packages\click\decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args[1:], **kwargs)
File "C:\Python27\lib\site-packages\click\core.py", line 535, in invoke
return callback(*args, **kwargs)
File "C:\Python27\lib\site-packages\samcli\commands\package\__init__.py", line 22, in cli
do_cli(args) # pragma: no cover
File "C:\Python27\lib\site-packages\samcli\commands\package\__init__.py", line 26, in do_cli
execute_command("package", args)
File "C:\Python27\lib\site-packages\samcli\lib\samlib\cloudformation_command.py", line 17, in execute_command
subprocess.check_call([aws_cmd, 'cloudformation', command] + list(args))
File "C:\Python27\lib\subprocess.py", line 535, in check_call
retcode = call(*popenargs, **kwargs)
File "C:\Python27\lib\subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
However, running aws cloudformation directly, it works fine
aws cloudformation package --template-file template.yaml --s3-bucket bucketname --output-template-file packaged.yaml
produces
Uploading to a4821aad146adadb17f01f5464a4faa3 4950 / 4950.0 (100.00%)
Successfully packaged artifacts and wrote output template to file packaged.yaml.
Execute the following command to deploy the packaged template
aws cloudformation deploy --template-file D:\lambda\serverless-application-model\examples\apps\hello-world\packaged.yaml --stack-name <YOUR STACK NAME>
Also, the same error occurred when runing sam deploy while aws cloudformation deploy works fine.
hi peterpham complete the same problem. does you find a solution yet?
no unfortunately. I used a workaround by running aws cloudformation deploy.
As it didn't work for my entire workflow, I am back to use serverless framework sls for the time being.
Many thanks @heitorlessa,
I run 'pip install awscli' then run the sam package again, it work.
Can you run the aws command from your command line after pip install awscli? Keep in mind that you may have to close and re-launch the command shell.
I can confirm that even if my aws-cli tools worked perfectly (other than SAM) I also had to pip install awscli, otherwise I was facing the same issue as the gentleman who asked the question
The error message could indeed be improved :)
Running windows 7
As a new user, I found it confusing having to separately install the AWS CLI again via pip. Is there any interest in a patch to improve the error handling?
Think this has been fixed with the PR: https://github.com/awslabs/aws-sam-cli/pull/786
Especially on windows, I think it was difference between looking for aws.exe and not aws.cmd
Closing as #786 has been released already.
Most helpful comment
hey @kyeljmd, whenever you can, mind sharing the following as I don't have a Windows machine handy in here?
C:\Users\TEUSER\Envs\python2\Scripts\aws helpaws.cmd helpaws.cmdfails you can either install system wide or inside your Virtualenv run `pip install awsclisam packagewill executeawsCLI under the hood and if it can't find it'll fail which seems to be the case here - If that is confirmed, we should definitely improve the error messaging there.https://github.com/awslabs/aws-sam-cli/blob/9dcd0bc040b0b9c61d7b61cf36748d25de5ec0e5/samcli/lib/samlib/cloudformation_command.py#L13
An unrelated minor note though:
--userflag as VirtualEnv is self-contained already and this should workpip install aws-sam-cli