serverless-python-requirements icon indicating copy to clipboard operation
serverless-python-requirements copied to clipboard

Getting Error: ENOENT when trying to add a module with one folder

Open cscetbon opened this issue 4 years ago • 8 comments

All the files used can be found at https://github.com/cscetbon/sls-dd-missing-folder. Following https://www.npmjs.com/package/serverless-python-requirements, I can package functions f1 and f2, but not f3 which is in a folder:

$ sls package
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Excluding development dependencies...
Serverless: Injecting required Python packages to package...

  Error --------------------------------------------------

  Error: ENOENT: no such file or directory, open '.serverless/sources/f3-sls-no-such-folder-dev-f3.zip'
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.1.0
     Framework Version:         1.70.1
     Plugin Version:            3.6.11
     SDK Version:               2.3.0
     Components Version:        2.30.10

If I remove f3 from the configuration I got no problem. Somehow, having one more level breaks it.

cscetbon avatar May 14 '20 22:05 cscetbon

I ran into this same issue with my project.

cturner-confluent avatar May 29 '20 16:05 cturner-confluent

@cturner-confluent unfortunately there doesn’t seem to be much activity on that project when i see that no one responded in 15 days ...

cscetbon avatar May 29 '20 17:05 cscetbon

Yeah makes me sad the serverless framework is obviously more focused around a NodeJS dev env. I may just have to switch over to using that instead of python. I did see this article where it looks like they have a nested folder structure https://medium.com/@nate_mitchell/serverless-packaging-user-defined-python-modules-41808776eae0 but not sure if it really works.

cturner-confluent avatar May 29 '20 17:05 cturner-confluent

Yeah I think those modules should be part of the framework itself instead of being plugins cause those are general functionalities. At least a few languages other than nodes and ensure they are well supported

cscetbon avatar May 29 '20 22:05 cscetbon

Ran into this error myself and was able to resolve it by creating an empty requirements.txt file in the folder that contains the Lambda function module.

ComfyDust avatar Jan 13 '21 01:01 ComfyDust

I'm seeing a similar issue where the serverless framework is creating a zip file in the root of the serverless directory, but this plugin is looking for it as a nested file with a different naming convention.

created zip:

.serverless/dpf-python-test-lambda.zip

plugin error:

Error: ENOENT: no such file or directory, open '.serverless/path/to/my/lambda/function/python-SERVICE_NAME-dpf-python-test-lambda.zip'

where module = path/to/my/lambda/function/python

MichaelRBond avatar Mar 17 '21 13:03 MichaelRBond

Thanks to @ComfyDust , I create an empty file requirements.txt under each python folder, and the problem is gone. I have the below structure

src
  python1
    python1.py
    requirements.txt
  python2
    python2.py
    requirements.txt

ctrongminh avatar Dec 02 '21 07:12 ctrongminh

I had a different issue but similar ENOENT error message related with python3.9 After hours of digging I've found out the cause: When the serverless.yaml > provider > runtime = pythonX but you are using a different python version, you will get an ENOENT error. In my case I had runtime = 3.9 and local = 3.8. So learning: Make sure you use the same python version as referred on the provider > runtime. I hope this helps.

augustoqm avatar Mar 31 '22 19:03 augustoqm