Not able to push new lambda function changes via amplify push. Error: Could not find a pipenv site-packages directory
Note: If your issue/bug is regarding the AWS Amplify Console service, please log it in the Amplify Console GitHub Issue Tracker
Describe the bug A clear and concise description of what the bug is.
I am not able to do amplify push after making any changes to one of my lambda function. For example simply remove a single space.
I am receiving this error:
nstalling dependencies from Pipfile.lock (a65489)...
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
(node:52398) UnhandledPromiseRejectionWarning: Error: Could not find a pipenv site-packages directory at /Users/heng2j/.virtualenvs/collectorVideosProcessor-r9qVMPot/lib/python3.8/site-packages
at Object.getPipenvDir (/usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-python-function-runtime-provider/src/util/pyUtils.ts:24:9)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at /usr/local/lib/node_modules/@aws-amplify/cli/node_modules/amplify-python-function-runtime-provider/src/util/packageUtils.ts:27:21
(node:52398) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:52398) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Amplify CLI Version
You can use amplify -v to check the amplify cli version on your system
4.39.0
To Reproduce Steps to reproduce the behavior or terminal output if applicable
I am putting my python dependencies in another lambda layer for that lambda function at opt/python
And I am using runtime Python 3.7 instead. But I have tried to run Python 3.8
Expected behavior A clear and concise description of what you expected to happen.
Successful push changes to the lambda function.
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Mac
- Node Version. You can use
node -vto check the node version on your system v12.13.0
Additional context Add any other context about the problem here.
@heng2j I'm having the exact same issue. Have you found a workaround yet?
Hi @half2me , @heng2j
It looks like pipenv is missing. I have a following questions:
-
Are you able to push functions before this error(selecting python as runtime)?
-
Can you make sure you have pipenv installed and included in your PATH variable(make sure python verison > 3.8)?
@akshbhu
- I got this error the very first time I tried to push my python function.
- I have it installed:
➜ ~ python3 --version
Python 3.9.1
➜ ~ pipenv --version
pipenv, version 2020.11.15
Can you try this:
- Install pipenv using
pip install --user pipenv.This does a user installation to prevent breaking any system-wide packages. - Run
python -m site --user-baseto get your user base binary directory, append bin to the path and add this path to your $PATH variable. You canecho $PATHif its added or not. - Try
amplify pushagain.
Let me know if this works for you?
For me, I checked that I only have python3.7 in my lambda function's virtualenv. So I have to renamed it manually to 3.8 to fix this issue.
/Users/heng2j/.virtualenvs/collectorVideosProcessor-r9qVMPot/lib/python3.8/site-packages
@heng2j @half2me Are you'll unblocked on this issue?
Closing due to lack of response.
amplify pull did the trick for me. It must have recreated what was missing (obviously I already had python and pipenv). Think of it this way ... if you were to pick up on a brand new machine, you wouldn't have any of those files under ~/.local/share/virtualenvs or ~/.virtualenvs. That's technically what happened to me (migrated Amplify project to M1 Mac).
UPDATE: Scratch that. It appears I would have to run pull before push every time. It's no fix. I'll tell you what seems to reliably do the trick:
pipenv run amplify push
thanks @rt-demetri this worked for me
pipenv run amplify push
I had the same problem. For me, the solution to solve it was to call "python3 -m site --user-base" as @akshbhu said. And then go inside the folder created, and copy the site-package folder into the path given by the pipenv error.
I needed this for an amplify lambda, the default path is not the path used by my lambda.
I'm having a similar problem. When I add a new lambda function I have to cd into the folder and run pipenv shell, then amplify push works.
So I have to have a separate pipenv virtual environment for EVERY lambda function? Where are the docs on how to properly use pipenv and add a python lambda function with amplify. I should just be able to follow a doc and it should work.
But default i still get this issue and i can't do a amplify function build. Amplify CLI should fix this out of the box.
@bfleming-ciena i agree this is not resolved @jhockett can you reopen this
Also seeing this issue. Anyone find a workaround yet? Neither @rt-demetri or @bfleming-ciena solutions worked for me.
I had the same problem. For me, the solution to solve it was to call "python3 -m site --user-base" as @akshbhu said. And then go inside the folder created, and copy the site-package folder into the path given by the pipenv error.
I needed this for an amplify lambda, the default path is not the path used by my lambda.
This worked for me, I don't normally reply lol. Thank you and @akshbhu.
Maybe @heitorlessa can help with a suggestion on how to fix this in the Amplify cli?
For me, I checked that I only have python3.7 in my lambda function's virtualenv. So I have to renamed it manually to 3.8 to fix this issue.
/Users/heng2j/.virtualenvs/collectorVideosProcessor-r9qVMPot/lib/python3.8/site-packages
I have also encountered this problem. In my case, pipenv command makes ~/.local/share/virtualenvs/myPythonAmplify/lib/python3.8 But, I'm using python3.9 So, I change directory name from python3.8 to python3.9
I don't know why this works, but the problem is solved.
Now I can amplify push !!!
For me, I checked that I only have python3.7 in my lambda function's virtualenv. So I have to renamed it manually to 3.8 to fix this issue. /Users/heng2j/.virtualenvs/collectorVideosProcessor-r9qVMPot/lib/python3.8/site-packages
I have also encountered this problem. In my case, pipenv command makes ~/.local/share/virtualenvs/myPythonAmplify/lib/python3.8 But, I'm using python3.9 So, I change directory name from python3.8 to python3.9
I don't know why this works, but the problem is solved. Now I can
amplify push!!!
Funny thing you should mention that. I think each first time you run Python in an amplify project, it leaves behind version information in a pipfile or something like that. Subsequent runs with a different version of Python will see the different version listed and you run into situations such as this issue. Another coworker unknowingly updated the pipfile (by means of running a multitude of different pip/pipenv commands) and suddenly I’m not getting the error anymore. Next time I’m in that code, I’ll take a look at the commit.
That's right. Changing "python3.8 to python3.9 version" Methods was only possible once....
After that, I use pipenv run amplify push It's Works!!
Maybe my Python version and pipfile have compatibility confilcts.
Same problem just resolved.
There is a mistake in the project in my case. My college setup python 3.8 in the functions, but use 3.9 in the Pipefile under the root of project.
So pipenv kept looking for site-packages under python-3.9 instead of python-3.8.
After set python 3.8 in the pipefile, I followed what akshbhu said:
- pip install --user pipenv
- export PATH="$HOME/.cargo/bin:$HOME/.local/bin:$PATH"
- amplify push
It works now.