AWS Lambda "Cannot load native module 'Cryptodome.Hash._MD5'"

0

I recently added some dependencies to my serverless project and ran into the following error when invoking my newly deployed Lambda.


module initialization error: Cannot load native module 'Cryptodome.Hash._MD5': Trying '_MD5.cpython-36m-x86_64-linux-gnu.so': /var/task/vendored/Cryptodome/Util/../Hash/_MD5.cpython-36m-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory, Trying '_MD5.abi3.so': /var/task/vendored/Cryptodome/Util/../Hash/_MD5.abi3.so: cannot open shared object file: No such file or directory, Trying '_MD5.so': /var/task/vendored/Cryptodome/Util/../Hash/_MD5.so: cannot open shared object file: No such file or directory


This dependency stems from one of my other dependencies and I don't want to manually modify these dependencies to use a different package. I would also prefer to not set up a virtual Linux environment to package this project.

What can I do to better investigate this issue, and ideally, resolve it?

Justian Meyer

Posted 2019-08-08T20:45:49.633

Reputation: 111

I don't encounter this issue on my local dev instance running MacOS 10.13.6 and Python 3.6.0.

I did some research on this problem and here's what I've gathered:

  • Lambda runs on Linux and the package above may need to be built on a Linux environment to resolve correctly
  • pycryptodome may be a drop in replacement for pycrypto and may be causing some conflicts with Lambda's environment
  • < – Justian Meyer – 2019-08-09T18:14:34.677

No answers