Closed gnsallman closed 2 years ago
Hello @gnsallman,
If you are using Linux, then the init_oracle_client()
function will not load the client libraries.
You will have to load the client libraries externally through ldconfig utility or set the LD_LIBRARY_PATH
environment variable to the directories of the instant client libraries. If you want to avoid this, On Linux, you can alternatively install cx_Oracle and Instant Client RPM packages from yum.oracle.com, see yum.oracle.com/oracle-linux-python.html
Please check cx_Oracle installation documentation for Linux on cx-oracle.readthedocs.io/en/latest/user_guide/installation.html?highlight=linux#installing-cx-oracle-on-linux
That error suggests that you are not getting cx_Oracle but some shim that is masquerading as cx_Oracle. You can find out by printing the location of the module and examining it, like this:
import cx_Oracle
print(cx_Oracle)
I added
import inspect
print(cx_Oracle)
print("getfile:")
inspect.getfile(cx_Oracle)
and I get
<module 'cx_Oracle' (namespace)>
getfile:
[ERROR] TypeError: <module 'cx_Oracle' (namespace)> is a built-in module
which doesn't make sense. I can import the module in my local python interpreter fine so this is something with Lambda
I recall seeing some StackOverflow posts about configuring Instant Client on lambda. Check them out; they might also help you with Python.
I'll close this issue since installing on AWS is out of our knowledge area, but if you find a solution, feel free it note it here.
Python version: 3.8 Running on AWS Lambda cx_Oracle version installed via pip: 8.3.0 Oracle DB version: 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production Oracle Instant Client Basic Light Package downloaded: instantclient-basiclite-linux.x64-18.5.0.0.0dbru.zip
Code block:
The error I get is:
[ERROR] AttributeError: module 'cx_Oracle' has no attribute 'connect'
I was thinking it was a problem with the client libraries not being found, so I added
but then I got:
[ERROR] AttributeError: module 'cx_Oracle' has no attribute 'init_oracle_client'
I also tried downgrading cx_Oracle to 8.0.0 but still the same errors.
All I have in my lambda zip for cx_Oracle is the
cx_Oracle.cpython-36m-x86_64-linux-gnu.so
binary itself. Do I need anything else besides the client library?