localstack / chalice-local

Small wrapper script to use AWS Chalice with LocalStack
Apache License 2.0
21 stars 3 forks source link

cannot run chalice local on windows 11 : OSError: [WinError 193] %1 is not a valid Win32 application #9

Open ruellm opened 2 years ago

ruellm commented 2 years ago

i just installed chalice local thru: pip install chalice-local and i created project and run thru

PS C:\Scopic\workspace\AngioCloud\chalice-local-test\chalice-demo-sns> chalice-local local

C:\Scopic\workspace\AngioCloud\chalice-local-test\chalice-demo-sns>python C:\Users\user\AppData\Local\Programs\Python\Python37\Scripts\\chalice-local local
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\cli\__init__.py", line 599, in main
    return cli(obj={})
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\cli\__init__.py", line 147, in local
    server_factory, os.environ, project_dir)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\cli\reloader.py", line 111, in run_with_reloader
    start_parent_process(env)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\cli\reloader.py", line 56, in start_parent_process
    process.main()
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\cli\reloader.py", line 86, in main
    process = self._popen(sys.argv, env=self._env)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\subprocess.py", line 1207, in _execute_child
    startupinfo)
OSError: [WinError 193] %1 is not a valid Win32 application

pip 20.1.1 (python 3.7)

whummer commented 2 years ago

Hi @ruellm , thanks for reporting. Looking at the stacktrace, this looks more like an issue with the underlying chalice package itself, rather than chalice-local (chalice-local is only a thin wrapper script that configures AWS credentials and endpoints). Can you try upgrading the chalice package to the latest version?

Also, please note that the local command is not how the CLI is intended to be used. Instead, you can use the deploy commands directly, in order to deploy your chalice app to your LocalStack instance.

For example, using the hello-world Chalice sample app:

$ chalice-local deploy
Creating deployment package.
Reusing existing deployment package.
Creating IAM role: test-dev
Creating lambda function: test-dev
Creating Rest API
Resources deployed:
  - Lambda ARN: arn:aws:lambda:us-east-1:000000000000:function:test-dev
  - Rest API URL: https://oc6nvd38ta.execute-api.us-east-1.amazonaws.com/api/

If you then slightly change the endpoint to target the local endpoint in LocalStack, we can invoke the deployed API directly:

$ curl http://oc6nvd38ta.execute-api.localhost.localstack.cloud:4566/api/
{"hello":"world"}

Hope that helps - please keep us posted on how it goes.. Thanks!

ruellm commented 2 years ago

hey @whummer thanks and i followed the sample correctly and it works good, however, when i restarted my pc and run 'chalice-local deploy' I am now getting this error:

Install the latest PowerShell for new features and improvements! https://aka.ms/PSWindows

PS C:\Scopic\workspace\AngioCloud\ac_ws_imaging> chalice-local deploy

C:\Scopic\workspace\AngioCloud\ac_ws_imaging>python C:\Users\user\AppData\Local\Programs\Python\Python37\Scripts\\chalice-local deploy
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\deploy\deployer.py", line 382, in _validate_config
    validate_configuration(config)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\deploy\validate.py", line 42, in validate_configuration
    validate_route_content_types(routes, config.chalice_app.api.binary_types)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\deploy\validate.py", line 142, in validate_route_content_types
    _validate_entry_content_type(route_entry, binary_types)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\deploy\validate.py", line 158, in _validate_entry_content_type
    'binary support.' % (route_entry.view_name, binary, non_binary))
ValueError: In view function "create_screenshot", the content_types ['image/png'] support binary and ['application/json'] do not. All content_types must be consistent in their binary support.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\cli\__init__.py", line 599, in main
    return cli(obj={})
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\click\decorators.py", line 21, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\cli\__init__.py", line 206, in deploy
    deployed_values = d.deploy(config, chalice_stage_name=stage)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\deploy\deployer.py", line 353, in deploy
    return self._deploy(config, chalice_stage_name)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\deploy\deployer.py", line 359, in _deploy
    self._validate_config(config)
  File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\chalice\deploy\deployer.py", line 384, in _validate_config
    raise ChaliceDeploymentError(e)
chalice.deploy.deployer.ChaliceDeploymentError: ERROR - While deploying your chalice application, received the following error:

 In view function "create_screenshot", the content_types ['image/png'] support
 binary and ['application/json'] do not. All content_types must be consistent
 in their binary support.

Running ordinary 'chalice local" is OK and working.

whummer commented 1 year ago

Hi @ruellm - quick follow-up, have you been able to resolve this issue? Looks like something potentially related to the application itself - are you getting this error when deploying the hello-world Chalice sample app?

lakkeger commented 1 year ago

Hi! We just wanted to follow up on our last message to see whether your issue has been resolved. Were you able to get it working with the latest version of LocalStack? We would appreciate your feedback!