[英]AWS lambda of python runtime 3.7 using layer of runtime 3.6
I have the following:我有以下内容:
1. AWS (lambda) layer of runtime python 3.6. 1.运行时的AWS(lambda)层python 3.6。
2. A lambda function of runtime python 3.7 that uses the above layer. 2. 使用上述层的运行时 python 3.7 的 lambda function。
The layer packages it's modules in a zip with the required hierarhcy of "python/lib/python3.6/site-packages"
.该层将其模块打包在 zip 中,所需的层次结构为"python/lib/python3.6/site-packages"
。
The problem is that the lambda function does not find (ie fails to import) the layer modules, unless I explicitly do something like: sys.path.append('/opt/python/lib/python3.6/site-packages')
, which I feel is a workaround.问题是 lambda function 找不到(即无法导入)层模块,除非我明确执行以下操作: sys.path.append('/opt/python/lib/python3.6/site-packages')
,我觉得这是一种解决方法。
I would expect aws lambda framework to smoothly allow a 3.7 runtime to import modules from a layer with version < 3.7.我希望 aws lambda 框架能够顺利地允许 3.7 运行时从版本 < 3.7 的层导入模块。 (by adding the matching python path or by some other way). (通过添加匹配的 python 路径或通过其他方式)。
Is there such a way that I missed?有没有我错过的方式?
Thanks.谢谢。
This layer hierarchy python/lib/python3.6/site-packages
is not needed.不需要此层层次结构python/lib/python3.6/site-packages
。 You could just do pip install xxx -t folder
, zip it, upload it, and set an PYTHONPATH=/opt
environment variable.你可以做pip install xxx -t folder
, zip 它,上传它,然后设置一个PYTHONPATH=/opt
环境变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.