I have cx_Oracle installed and I can successfully import it. But when I try to establish an Oracle connection, I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle
My operating system is MacOSX, and my ORACLE_HOME is pointing to instantclient_11_2.
First thing first.
Check if your cx_oracle is built for the exactly same version as your Oracle client.
import cx_Oracle
cx_Oracle.clientversion()
This should return the version it's expecting to find.
If the versions differ, you should rebuild it against the correctly version.
For instant client, do not set ORACLE_HOME. Instead follow these instructions:
cd $HOME
mkdir -p lib
cd lib
cp /the/location/to/instantclient_11_2/*dylib* .
ln -s libclntsh.dylib.11.1 libclntsh.dylib
If you are able to use Instant Client 12.1 things are a bit simpler
cd $HOME
mkdir -p lib
cd lib
ln -s /the/location/to/instantclient_12_1/libclntsh.dylib.12.1 libclntsh.dylib
If you also download and extract the SQL*Plus package you can verify that your client installation is working properly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With