I recently uninstalled python 3.10.x to put on 3.9.x as my company literally uses 3.9.x everywhere and 3.10.x was causing issues for me. After doing that I created a hello_world from sam cli and also made a VENV and did the following commands.
1st set of commands
source ./venv/bin/activate
python -m pip install --upgrade pip &&
python -m pip install --upgrade setuptools &&
pip install -r requirements.txt --upgrade (I have also tried with --no-cache-dir)
After everything was installed I ran the following commands to get the sam up and running locally
2nd set of commands
sam build
sam local start-api
When I run all of the commands 1st time they work fine, but as soon as I ctrl+c to close the local service I get 1 of the 2 errors. It can be either config_dir another time it can be project_files and I do not have a clue what is causing this. I've tried a number of re-creations of venv and nothing changes. Also after I get the error I can no longer use the same instance of my terminal and I have to start a new instance inside VSCode. I'm using Ubuntu WSL on a Windows Machine.
1st
Traceback (most recent call last):
File "/mnt/c/Main Storage/_GitHub Repos/service-translation/venv/bin/sam", line 10, in <module>
sys.exit(cli())
File "/mnt/c/Main Storage/_GitHub Repos/service-translation/venv/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/mnt/c/Main Storage/_GitHub Repos/service-translation/venv/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/mnt/c/Main Storage/_GitHub Repos/service-translation/venv/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/mnt/c/Main Storage/_GitHub Repos/service-translation/venv/lib/python3.9/site-packages/click/core.py", line 1257, in invoke
sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
File "/mnt/c/Main Storage/_GitHub Repos/service-translation/venv/lib/python3.9/site-packages/click/core.py", line 700, in make_context
self.parse_args(ctx, args)
File "/mnt/c/Main Storage/_GitHub Repos/service-translation/venv/lib/python3.9/site-packages/click/core.py", line 1048, in parse_args
value, args = param.handle_parse_result(ctx, opts, args)
File "/mnt/c/Main Storage/_GitHub Repos/service-translation/venv/lib/python3.9/site-packages/click/core.py", line 1630, in handle_parse_result
value = invoke_param_callback(self.callback, ctx, self, value)
File "/mnt/c/Main Storage/_GitHub Repos/service-translation/venv/lib/python3.9/site-packages/click/core.py", line 123, in invoke_param_callback
return callback(ctx, param, value)
File "/mnt/c/Main Storage/_GitHub Repos/service-translation/venv/lib/python3.9/site-packages/samcli/cli/cli_config_file.py", line 133, in configuration_callback
config_dir = getattr(ctx, "samconfig_dir", None) or os.getcwd()
FileNotFoundError: [Errno 2] No such file or directory
2nd
CTraceback (most recent call last):
File "/mnt/c/Users/marti/OneDrive/Desktop/AWS Lambda Dockerfile/powertools-quickstart/venv/bin/sam", line 10, in <module>
sys.exit(cli())
File "/mnt/c/Users/marti/OneDrive/Desktop/AWS Lambda Dockerfile/powertools-quickstart/venv/lib/python3.9/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/mnt/c/Users/marti/OneDrive/Desktop/AWS Lambda Dockerfile/powertools-quickstart/venv/lib/python3.9/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/mnt/c/Users/marti/OneDrive/Desktop/AWS Lambda Dockerfile/powertools-quickstart/venv/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/mnt/c/Users/marti/OneDrive/Desktop/AWS Lambda Dockerfile/powertools-quickstart/venv/lib/python3.9/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/mnt/c/Users/marti/OneDrive/Desktop/AWS Lambda Dockerfile/powertools-quickstart/venv/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/mnt/c/Users/marti/OneDrive/Desktop/AWS Lambda Dockerfile/powertools-quickstart/venv/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/mnt/c/Users/marti/OneDrive/Desktop/AWS Lambda Dockerfile/powertools-quickstart/venv/lib/python3.9/site-packages/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/mnt/c/Users/marti/OneDrive/Desktop/AWS Lambda Dockerfile/powertools-quickstart/venv/lib/python3.9/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/mnt/c/Users/marti/OneDrive/Desktop/AWS Lambda Dockerfile/powertools-quickstart/venv/lib/python3.9/site-packages/samcli/lib/telemetry/metric.py", line 153, in wrapped
project_type = ProjectTypes.CDK.value if is_cdk_project(template_dict) else ProjectTypes.CFN.value
File "/mnt/c/Users/marti/OneDrive/Desktop/AWS Lambda Dockerfile/powertools-quickstart/venv/lib/python3.9/site-packages/samcli/lib/iac/cdk/utils.py", line 27, in is_cdk_project
_relevant_cdk_files_are_present(),
File "/mnt/c/Users/marti/OneDrive/Desktop/AWS Lambda Dockerfile/powertools-quickstart/venv/lib/python3.9/site-packages/samcli/lib/iac/cdk/utils.py", line 73, in _relevant_cdk_files_are_present
project_files = os.listdir(os.getcwd())
FileNotFoundError: [Errno 2] No such file or directory
IMPORTANT: If you want to re-create the with same steps as I did here's exactly what I've done.
sam init --runtime python3.9 --dependency-manager pip --app-template hello-world --name powertools-quickstart
cd powertools-quickstart
python3.9 -m venv venv
Execute the 1st set of commands I've added to this post above.
Execute the 2nd set of command I've added to this post above.