- Newest
- Most votes
- Most comments
Hello,
This issue usually occurs if the path defined within amplify.yml isn't able to identify the appropriate python version, pipenv. In order to mitigate the issue, make sure that your system has pipenv installed by running "pip3 install pipenv" command. Further, after adding the python rest api/function to the amplify project using "amplify add api" command. Then, edit the pipfile and make sure you have the python_version set to value "3.9". As next step, edit the cloudformation.json file and make sure the "Runtime": "python3.9" is configured appropriately. Lastly, on amplify console, edit the Amplify.yml file in the build settings and have the below configurations :
--------------------------------------------
backend:
phases:
build:
commands:
- update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.9 15
- /usr/local/bin/python3.9 -m pip install --upgrade pip
- /usr/local/bin/pip3.9 install --user pipenv
- amplifyPush --simple
--------------------------------------------
I have also found similar issue over this documentation [1] and kindly refer the steps mentioned over the docs if that helps in mitigating the issue.
Please do let us know if that resolves the issue. If you still encounter the issue, then kindly share the amplify.yml file with us as it will help in identifying the issue.
Thank you.
References:
I have already updated python version at respective files.
/my_repo/amplify/backend/function/myUserHandler/Pipfile: 12: python_version = "3.9" /my_repo/amplify/backend/function/myUserHandler/Pipfile.lock: 8: "python_version": "3.9" /my_repo/amplify/backend/function/myUserHandler/myUserHandler-cloudformation-template.json: 81: "Runtime": "python3.9",
Added initial build file to question. Build logs after updating build file as mentioned above.
2024-04-26T09:49:53.033Z [INFO]: ## Starting Backend Build # Starting phase: build # Executing command: update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.9 15 2024-04-26T09:49:53.204Z [WARNING]: failed to create /var/lib/alternatives/python3.new: Permission denied 2024-04-26T09:49:53.205Z [ERROR]: !!! Build failed 2024-04-26T09:49:53.205Z [ERROR]: !!! Error: Command failed with exit code 2
Relevant content
- asked a year ago
- asked 6 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- How do I install and troubleshoot Python libraries in Amazon EMR and Amazon EMR Serverless clusters?AWS OFFICIALUpdated a month ago
Having the same issue