简体   繁体   English

AWS lambda 的 python 运行时 3.7 使用运行时层 3.6

[英]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.

相关问题 AWS Lambda Python 3.7运行时异常日志记录 - AWS Lambda Python 3.7 runtime exception logging 在运行时导入Python 3.6 - Python 3.6 import at runtime 使用python3.6运行时在Lambda函数中运行Perl脚本 - Running perl script in lambda function with python3.6 runtime AWS Lambda Python 错误 - Runtime.ImportModuleError - AWS Lambda Python error - Runtime.ImportModuleError 如何使用 AWS Lambda 层使用 Python? - How to use AWS Lambda layer using Python? Runtime.ImportModuleError: Unable to import module &#39;testsdk&#39;: No module named &#39;jsonpickle&#39; with Python script using AWS Lambda - Runtime.ImportModuleError: Unable to import module 'testsdk': No module named 'jsonpickle' with Python script using AWS Lambda AWS Lambda Docker 自定义 Python 库 (Runtime.ImportModuleError) - AWS Lambda Docker Custom Python Library (Runtime.ImportModuleError) 将AWS Lex集成到网站(在python运行时中实现的lambda) - Integrate AWS Lex to website(lambda implemented in python runtime) 如何解决“ RuntimeWarning:模块&#39;tensorflow.python.framework.fast_tensor_util&#39;的编译时版本3.6与运行时版本3.7不匹配”? - How to fix “RuntimeWarning: compiletime version 3.6 of module 'tensorflow.python.framework.fast_tensor_util' does not match runtime version 3.7”? 即使更新了通用 C 运行时,Python 3.5x、3.6x 和 3.7x 安装也会在 Windows 7 上失败 - Python 3.5x, 3.6x and 3.7x Install Fails on Windows 7 even with Universal C runtime updated
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM