I’m trying to use libraries in my python backend.
I have it deployed with serverless framework. This is my configuration:
serverless.yml:
plugins:
- serverless-offline
- serverless-python-requirements
custom:
pythonRequirements:
dockerizePip: non-linux
zip: true
functions:
function1:
handler: handlerPV.function1
events:
- httpApi:
path: /function1
method: post
function2:
handler: handlerPV.function2
events:
- httpApi:
path: /function2
method: post
function3:
handler: handlerPV.function3
events:
- httpApi:
path: /function3
method: post
(I have changed the names of the functions to show it here)
My .requirements.txt:
cachetools==5.3.2
certificate==2023.11.17
charset-normalizer==3.3.2
dnspython==2.3.0
idna==3.6
numpy==1.21.6
numpy-financial==1.0.0
pymongo==4.6.1
requests==2.31.0
urllib3>=1.26.0,<2.0.0
boto3==1.33.13
The problem I’m having is that when I upload it to AWS with the serverless deploy
command I get this error in only some lambda functions. It’s strange, because some functions use this library and it works, but in others, it doesn’t work..
This is the error un cloudWatch:
[ERROR] Runtime.ImportModuleError: Unable to import module 'handlerSimulationDatabase': No module named 'cachetools' Traceback (most recent call last):