Reputation: 104
I am trying to connect to an Oracle db from AWS Lambda
using python. I managed to package cx_Oracle but the environment does not find the dependencies.
I had zipped the content, which contained cx_Oracle.so
and cx_Oracle-5.2.1-py2.7.egg-info
(created on 64bit AWX Linux). I also added the files from instantclient-basic-linux.x64-12.1.0.2.0.zip
into local/lib in that zip file.
The error I get is
import cx_Oracle
ImportError: libaio.so.1: cannot open shared object file: No such file or directory
I dynamically change environment variables in python like so:
oracledir = os.path.join(os.getcwd(), 'local', 'lib')
libdir = os.environ['LD_LIBRARY_PATH'] + ":" + os.path.join(os.getcwd(), 'local', 'lib')
command = 'LD_LIBRARY_PATH={} ORACLE_HOME={} python OracleWorker.py "{}"'.format(libdir, oracledir, args)
subprocess.call(command, shell=True)
OracleWorker.py starts with import cx_Oracle
Upvotes: 2
Views: 5892
Reputation: 104
Resolved. Added all dependencies by running
ldd cx_Oracle.so| grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /destination
Added all those files in destination to lib folder in lambda zip
Upvotes: 2