admin管理员组文章数量:1390571
I did try the 2 solutions - nesting properly my Python libs inside zip folder:
layer_content.zip
└ python
└ lib
└ python3.11
└ site-packages
└ requests
└ <other_dependencies> (i.e. dependencies of the requests package)
└ ...
and following another tip that Amazon just changed its requirement and all libs should go directly into python folder. But both options don't work.
my_layer.zip:
- python
- requests
- psycopg2
- snowflake-connector
my_layer_nested.zip:
└ python
└ lib
└ python3.11
└ site-packages
└ requests
└ snowflake-connector
Neither work, it does not see the requests module:
import json
import requests
def lambda_handler(event, context):
url = ";
response = requests.get(url)
return {
'statusCode': 200,
'body': json.dumps({
'message': 'Layer test successful!',
'data': response.json()
})
}
I tried using both separate zip folders as layers, here is the output:
Status: Failed
Test Event Name: kljlj
Response:
{
"errorMessage": "Unable to import module 'lambda_function': No module named 'requests'",
"errorType": "Runtime.ImportModuleError",
"requestId": "",
"stackTrace": []
}
本文标签: pythonHow to import any lib from zip lambda layer despite nesting libs properlyStack Overflow
版权声明:本文标题:python - How to import any lib from zip lambda layer despite nesting libs properly - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744663247a2618374.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论