When trying to run amplify push why is it looking in the wrong location for python

1.7k views Asked by At

I have an AWS Amplify project and am trying to add lambda functions using python 3.8 runtime.

I initially had Python 3.9 installed, however the lambda functions would only support 3.8

So I uninstalled 3.9 and installed 3.8

Now when I run 'Amplify push' I get the following error

ss I have tried uninstalling and reinstalling python & pipenv & Amplify CLI.

"3.9" is not mentioned in the pipfile or anywhere else in the project, nor in my environment variables.

I don't know why Amplify is looking here for the Python installation, if I run 'Python --version' it prints 3.8

How can I get change the location of where it's searching?

2

There are 2 answers

0
MonoThreaded On

I found two separate issues that gave me this symptom

  1. Wrong Python installation (mistake on my part)
    • I was trying to build a 3.8 Lambda on Python 3.11 => Forget about it. Just install the version that matches your backend and be happy.
  2. Trying to run with the correct Python (but the old setup was sticky)
    • once you invoke pipenv once, it remembers and expects Python to be in the same place. You can erase it's previous settings with pipenv --rm
C:\{project-root}\amplify\backend\function\{function-name}> pipenv --rm
Removing virtualenv (C:\Users\{username}\.virtualenvs\{function-name}-C7dwlRZ3)

You need to do this for all lambdas

0
fanando On

Same problem here, I added a path for python3 and it solved it, I think amplify prefers