terraform-aws-modules/terraform-aws-lambda

Python interpreter version equal to defined lambda runtime (python3.9) should be available in system │ PATH

idjelaili opened this issue · 3 comments

Hello,
I have this error when executing terraform plan on my local machine with windows 10
Everything work when executing it in a pipeline with a linux machine
I verified that I have a python 3.9 installed and added in my path variable and even in the error message the program use the right python interpreter
I don't know why I'm still getting this error
Thank you for your help

The data source received an unexpected error while attempting to execute the program.

│ Program: C:\Users\imad.djelalli\AppData\Local\Programs\Python\Python39\python.exe
│ Error Message: Traceback (most recent call last):
│ File "C:\Users\imad.djelalli\Desktop\seloger\aviv-republication-detection-infra\terraform.terraform\modules\lambda_duplication_process\package.py", line 1632, in
│ main()
│ File "C:\Users\imad.djelalli\Desktop\seloger\aviv-republication-detection-infra\terraform.terraform\modules\lambda_duplication_process\package.py", line 1628, in main
│ exit(args.command(args))
│ File "C:\Users\imad.djelalli\Desktop\seloger\aviv-republication-detection-infra\terraform.terraform\modules\lambda_duplication_process\package.py", line 1427, in prepare_command
│ build_plan = bpm.plan(source_path, query)
│ File "C:\Users\imad.djelalli\Desktop\seloger\aviv-republication-detection-infra\terraform.terraform\modules\lambda_duplication_process\package.py", line 801, in plan
│ pip_requirements_step(pip_requirements, prefix,
│ File "C:\Users\imad.djelalli\Desktop\seloger\aviv-republication-detection-infra\terraform.terraform\modules\lambda_duplication_process\package.py", line 675, in pip_requirements_step
│ raise RuntimeError(
│ RuntimeError: Python interpreter version equal to defined lambda runtime (python3.9) should be available in system
│ PATH

The error is happening when the module try to install dependencies from requirements.txt when i delete the pip_requirements line from the module definition the terraform plan works fine
I even delete all python versions from my computer and keeping only the 3.9 version but still getting the error

By looking at the package.py file in the generated module files in .terraform/ folder (created after the terraform init command) I noticed that the function that install requirements try to do shutil.which(command) and command=runtime which equal python3.9 in my case. This function return None that's why I had the exception above
I just created an alias mklink "C:\path\to\Python39\python3.9.exe" "C:\path\to\Python39\python.exe" and now it works fine
I will close the ticket

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.