在 AWS lambda 导入错误中调用 python

Invoking python in AWS lambda import error

我正在尝试在 AWS lambda 函数中调用 python 脚本。我已经为 python 创建了一个虚拟环境并安装了 pandas、pymongo 等需要的模块。这是我的 invokepython.js:

var exec = require('child_process').exec;
exports.handler = function(event, context) {
    console.log('Received event:', JSON.stringify(event, null, 2));
    exec("env/bin/python kinesisconsumer.py '"+ JSON.stringify(event) +"'", function(error, stdout) {
    console.log('Python returned: ' + stdout + '.');
    context.done(error, stdout);
});
};

我已经安装了 virtualenv 并使用它创建了一个环境。使用 env/bin/pip install pandas 我安装了 pandas。我已将 env 文件夹和我的脚本压缩在一起并将其部署到 AWS lambda 但出现错误。

{
  "errorMessage": "Command failed: Traceback (most recent call last):\n  File \"kinesisconsumer.py\", line 4, in <module>\n    import pandas as pd\n  File \"/var/task/env/local/lib/python2.7/site-packages/pandas/__init__.py\", line 13, in <module>\n    \"extensions first.\".format(module))\nImportError: C extension: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.\n",
  "errorType": "Error",
  "stackTrace": [
    "  File \"kinesisconsumer.py\", line 4, in <module>",
    "    import pandas as pd",
    "  File \"/var/task/env/local/lib/python2.7/site-packages/pandas/__init__.py\", line 13, in <module>",
    "    \"extensions first.\".format(module))",
    "ImportError: C extension: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.",
    "",
    "ChildProcess.exithandler (child_process.js:658:15)",
    "ChildProcess.emit (events.js:98:17)",
    "maybeClose (child_process.js:766:16)",
    "Process.ChildProcess._handle.onexit (child_process.js:833:5)"
  ]

我需要在 AWS lambda 上使用 pandas。我应该如何解决这个问题。感谢任何帮助!!!

我在 Amazon Linux 上做的所有事情都和在我的 ubuntu 机器上做的一样。它的工作。解释 here

In order to work in AWS Lambda, extension modules need to be compiled for Amazon Linux x86_64"