Unable to load native module

0

I have a very small python script that returns the error.

I have packed this up two ways and get the same error. I have installed the packages directly to the folder, and then zipped. And I have also created a virtual environment, installed the packages and then zipped. I still get the same result.

I have had a look but couldn't find a solution to this.

Does anyone know why this isn't working?

Error code below:

{
  "errorMessage": "Cannot load native module 'Crypto.Hash._SHA256': Trying '_SHA256.cpython-37m-x86_64-linux-gnu.so': /var/task/Crypto/Util/../Hash/_SHA256.cpython-37m-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory, Trying '_SHA256.abi3.so': /var/task/Crypto/Util/../Hash/_SHA256.abi3.so: cannot open shared object file: No such file or directory, Trying '_SHA256.so': /var/task/Crypto/Util/../Hash/_SHA256.so: cannot open shared object file: No such file or directory",
  "errorType": "OSError",
  "stackTrace": [
    "  File \"/var/lang/lib/python3.7/imp.py\", line 234, in load_module\n    return load_source(name, filename, file)\n",
    "  File \"/var/lang/lib/python3.7/imp.py\", line 171, in load_source\n    module = _load(spec)\n",
    "  File \"<frozen importlib._bootstrap>\", line 696, in _load\n",
    "  File \"<frozen importlib._bootstrap>\", line 677, in _load_unlocked\n",
    "  File \"<frozen importlib._bootstrap_external>\", line 728, in exec_module\n",
    "  File \"<frozen importlib._bootstrap>\", line 219, in _call_with_frames_removed\n",
    "  File \"/var/task/main.py\", line 3, in <module>\n    from coinbase.wallet.client import Client\n",
    "  File \"/var/task/coinbase/wallet/client.py\", line 39, in <module>\n    from Crypto.Hash import SHA256\n",
    "  File \"/var/task/Crypto/Hash/SHA256.py\", line 47, in <module>\n    \"\"\")\n",
    "  File \"/var/task/Crypto/Util/_raw_api.py\", line 300, in load_pycryptodome_raw_lib\n    raise OSError(\"Cannot load native module '%s': %s\" % (name, \", \".join(attempts)))\n"
  ]
}
asked 5 years ago1159 views
1 Answer
0
Accepted Answer

If you compiled on your local computer, it probably generated a different format of library than the lambda environment can use. pycrypto does not provide prebuilt wheels, so you'll need to compile it in an environment that matches what lambda runs: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

Ellison
answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions