- Newest
- Most votes
- Most comments
So I was able to finally find the solution to this.
Looking at the provision logs I noticed that the image it was provisioning was including python 3.7, 3.8, and 3.9. So if I left the default when adding an API it was defaulting to the 3.7 error. I was changing it to push 3.10 instead which wasn't a built in option to the image. For now, I am just going to use the 3.9 until Amplify updates the image.
- First I cleaned my own system
pip3 uninstall pipenv
rm -rdf /home/<user>/.pyenv
- Then I reinstalled pipenv
pip3 install pipenv
- Then reinstall pyenv
curl https://pyenv.run | bash
- Then added the python rest api/function to the amplify project
amplify add api
- Then edited the pipfile
[requires]
python_version = "3.9"
- Then edited the cloudformation.json file
"Runtime": "python3.9",
- Next I went to the Amplify console and edited the Amplify.yml file in the build settings
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 then pushed to Amplify
amplify push
Finally the entire build process worked and things are up and running with a Python based API added to the project. Hopefully this helps anyone else running into this error.
EDIT: Found this that helped resolve it https://github.com/aws-amplify/amplify-hosting/issues/595
This is actually not an error. Its level is just Info
. If you add requirements.txt
to your code directory, I think this message should be eliminated.
2023-09-09T15:05:52.019Z [INFO]: 🛑 Missing required dependencies to package PythonAPITest
Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/
So I assume you mean putting that in the
amplify\backend\function\<projectname>\
directory I tried putting one there and it didn't seem to make a difference.I encountered the following error when I tried to amplify to add the python api:
🛑 You must have pipenv installed and available on your PATH as "pipenv". It can be installed by running "pip3 install --user pipenv". You must have virtualenv installed and available on your PATH as "venv". It can be installed by running "pip3 install venv". 🛑 Missing required dependencies to package blog1802734b
Then I fixed this error by executing command like below:
pip3 install --user pipenv pip3 install --user virtualenv
I don't know what your code looks like, maybe you can try updating amplify to the latest version and try again.
So I updated Amplify however it still breaks. I see this in the build logs
2023-09-28T02:42:04.324Z [INFO]: 🛑 python3 found but version Python 3.7.15 is less than the minimum required version. You must have python >= 3.8 installed and available on your PATH as "python3" or "python". It can be installed from https://www.python.org/downloads You must have pipenv installed and available on your PATH as "pipenv". It can be installed by running "pip3 install --user pipenv". You must have virtualenv installed and available on your PATH as "venv". It can be installed by running "pip3 install venv". 2023-09-28T02:42:04.325Z [WARNING]: ✖ There was an error initializing your environment. 2023-09-28T02:42:04.325Z [INFO]: 🛑 Missing required dependencies to package viteproject1b8d2931 2023-09-28T02:42:04.325Z [INFO]: Learn more at: https://docs.amplify.aws/cli/project/troubleshooting/ 2023-09-28T02:42:04.345Z [INFO]: Session Identifier: 7c7879d5-7f21-47dd-be1e-f80bb819f749 2023-09-28T02:42:04.367Z [ERROR]: !!! Build failed 2023-09-28T02:42:04.368Z [ERROR]: !!! Non-Zero Exit Code detected 2023-09-28T02:42:04.368Z [INFO]: # Starting environment caching... 2023-09-28T02:42:04.368Z [INFO]: # Uploading environment cache artifact...
However, I confirmed that on my laptop every thing is correct. I'm not sure how I can fix the build process for the AWS side.
you are almost done, Just do the following things:
-
Install python after version 3.8
-
Install "pipenv":
pip3 install --user pipenv
-
Install "venv":
pip3 install --user virtualenv
-
for
pipenv
andvirtualenv
I getrequirement already satisfied
If I runpython --version
I getpython command not found
if I runpython3 --version
I getversion: 3.10.12
Relevant content
- Accepted Answerasked a year ago
- asked 5 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 months ago
Its Not working in my case
Executing command: update-alternatives --install /usr/bin/python3 python3 /usr/local/bin/python3.9 15 2024-04-24T06:58:41.387Z [WARNING]: failed to create /var/lib/alternatives/python3.new: Permission denied