Py3: Can't open file /snapshot/serverless/lib/plugins/aws/invokeLocal/invoke.py : No such file or directory

Viewed 938

I am trying to test the serverless lambda function locally using the command Command

serverless invoke local -f send --log --stage test

Error

python3: can't open file '/snapshot/serverless/lib/plugins/aws/invokeLocal/invoke.py': [Errno 2] No such file or directory

This command is run inside the directory which has serverless.yml, requirements.txt, handler.py.

Unable to understand why this error occurs and what's the solution

2 Answers

I had the same error. The result of my serverless --version command is

Framework Core: 1.66.0 (standalone)
Plugin: 3.4.1
SDK: 2.3.0
Components: 2.22.3

Solution

First, if you installed with the command of curl -o- -L https://slss.io/install | bash, uninstall it with the following command:

serverless uninstall

Next, install with the following command:

npm install -g serverless@1.43.0
npm bin serverless

Now the serverless --version command looks like this:

1.43.0

that's all

The venv module doens't create a binary at $VIRTUAL_ENV/bin/pythonX.Y like virtualenv does.

As a work around for now, create a python3.6 symlink:

cd venv/bin
ln -s python3 python3.6
Related