2

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

2
  • Its not worth asking the same question over - please edit your previous question Commented Jun 9, 2016 at 20:18
  • 1
    The previous question was regarding a tutorial which was against the policy. The answer you provided was the generic aws tutorial which did not help on this case. The question above details the exact steps I have taken and results I am getting. Please again note that I did follow that tutorial as a first step without results. Commented Jun 9, 2016 at 23:12

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

1 Comment

Hi @Thomas, I am getting this error """DPI-1047: 64-bit Oracle Client library cannot be loaded: \"libclntsh.so: cannot open shared object file: No such file or directory\""" I have put all the files in of instantclient_12_12 into lib folder and index.py along with cx_Oracle at the same level as lib. Can you please share your zip or the directory structure. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.