我有几个lambda函数,并且知道如何构建和导出要在lambda环境中使用的python库。不幸的是,我遇到了numpy的问题。
所以我有一个运行Python3.6.0的EC2环境(Amazon Linux AMI),它等同于在我的Lambda函数上运行的Python版本。我已经构建了numpy==1.12.0。然后我将其导出到我的Lambda函数。不幸的是,在调用函数时,我得到了以下错误:
START RequestId: e0f95294-c7a0-11e7-973e-7b655ecd81b6 Version: $LATEST
Unable to import module 'lambda':
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.发布于 2019-11-20 00:58:26
我也有同样的问题。我发现现在这是一个很常见的问题。暂时,我建议您使用在Python解释器版本中编译的所有库。在您的例子中是Python3.6,然后压缩它。并将其加载到lambda函数的目录中。这是我找到的解决这个问题的唯一办法。
使用外壳命令zip -9 -r dirname压缩库您需要使用"-r“来递归压缩,并且需要使用"9”来尽可能地压缩。
GoodLuck!
https://stackoverflow.com/questions/47248531
复制相似问题