I'm using Python 3.1.2. I've downloaded cx_Oracle (Windows x86 Installer (Oracle 10g, Python 3.1)). I'm using Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64-bit.
I'm trying to access a remote Oracle server. I haven't installed any Oracle client. However, I use SQLTools 1.5.0, which I manually copy-pasted from some place.
I came to know cx_Oracle needs a DLL file from an Oracle client to access a remote database, so I copied all the DLL files from the folder of SQLTools to a location. I added the location where I kept the ora.dll into the system's environment variable (PATH and ORACLE_HOME). But it doesn't seem to work. I get the same error:
ImportError: DLL load failed: The specified module could not be found.
I'm missing something. Will this manual work do the job or do I have to install an Oracle client?
The Oracle client isn't an installer, but a series of zip packages. Download the appropriate Instant Client from this here (http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html), unzip them, stick them on your C drive or anywhere you prefer, and add it to your LD_LIBRARY_PATH and ORACLE_HOME env vars.
Related
I have installed cx_oracle(python3) and instant client 21_1 inside a container. When I try to first time I got this error
Cannot locate a 64-bit Oracle Client library: "/python-
env/instantclient_21_1/lib/libclntsh.so:
So I have created lib under /python-env/instantclient_21_1/ and tried again, now I'm getting this error
cx_Oracle.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libnnz19.so: cannot open shared object file: No such file or directory". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help
I don't understand where is it searching for the that so file. It is already present in /python-
env/instantclient_21_1/lib/
Please help
Follow the Instant Client installation steps or cx_Oracle Installation steps and use ldconfig to set the library path to include the Instant Client directory.
You could set DPI_DEBUG_LEVEL=64 (see here) to trace how cx_Oracle is looking for the libraries.
Also see Docker for Oracle Database Applications in Node.js and Python.
I am trying to connect to oracle DB to execute some SQL queries and fetch data through a python script . I have imported cx_Oracle and tried connecting.I got the error as - Exception - DPI-1047: Cannot locate a 64-bit Oracle Client library: "libclntsh.so: cannot open shared object file: No such file or directory". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help was raised.
I downloaded instaclient and used that in my script and it worked using the below commands :
LOCATION = r"C:\instantclient_19_5"
os.environ["PATH"] = LOCATION + ";" + os.environ["PATH"]
But now I need to use this in CI CD pipeline. I have created a docker image for instaclient and python I am trying use this into my script. But I am not sure how to use add instaclient location in script (like the above code snippet) Could you please help me with this.
If you were deploying to Windows (or macOS), you could have used the new cx_Oracle 8 init_oracle_client() function, which is preferred to fiddling with PATH.
However it seems you are deploying to Linux, meaning the system library search path needs to contain all library directories before the process start. So you need to use ldconfig or set LD_LIBRARY_PATH as traditionally used on Linux. The cx_Oracle doc Installing cx_Oracle on Linux and Locating the Oracle Client Libraries covers this.
Also see sample docker images for Linux developers and for basic Oracle Instant Client. If you are not on an RPM based system, check out the sample Docker files in Docker for Oracle Database Applications in Node.js and Python.
In summary, download Oracle Instant Client Basic or Basic Light packages from here. If you got the ZIP files then run something like:
RUN echo /opt/oracle/instantclient_19_8 > /etc/ld.so.conf.d/oic.conf && \
ldconfig
The details vary with what base Docker image you are using, and whether you want to install Instant Client from ZIP files or RPMs.
I have a Python connection issue using cx-Oracle - I am unable to connect to the database.
I need to install the Oracle client at the machine in offline mode, so I have unzipped the source file.
I have unzipped the 64 bit version of the Oracle client tool and saved in the opt folder in linux.
My machine has an updated version of the libaio package.
LD_LIBRARY_PATH is also set and points to the opt folder client files.
But I still get the following error:
Check from python:
(Your version may be other than 11.2).
print(os.environ["LD_LIBRARY_PATH"])
There should be something as:
/usr/lib/oracle/11.2/client64/lib
And check that exists file /usr/lib/oracle/11.2/client64/lib/libclntsh.so
I am trying to run a code to create tables in oracle database.I am using Python 3.6.5 and Oracle Database 10g Express Edition Release 10.2.0.1.0 in windows 64 bit.
con=cx_Oracle.connect(config.connection)
cx_Oracle.DatabaseError: DPI-1047: 64-bit Oracle Client library cannot be loaded: "C:\oraclexe\app\oracle\product\10.2.0\server\bin\oci.dll is not the correct architecture".
Seems like you are unable to connect to the Oracle DB. As pointed out here:
You need to install cx_Oracle extension for python and make sure environment variables are correctly set
In addition, see that the credentials in config.connection are correct.
Update: the latest major release of the cx_Oracle driver doesn't need Oracle libraries by default, so configuration is easier. The driver got renamed to python-oracledb, see the release announcement.
cx_Oracle 6+ needs to be using Oracle 11.2+ libraries. It seems you are linking it with your 10g DB libraries. You can install 11.2 libraries using the free Oracle Instant Client, set PATH to include them, and then connect to your 10g database - but don't stuff up PATH for other applications that need the 10g libraries. You'll probably need to use something like a BAT script to set PATH and then call python.
The Oracle 11.2 libraries must be the same 32-bit or 64-bit as Python is.
If there's anything unclear in https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html then log an issue on the cx_Oracle project at https://github.com/oracle/python-cx_Oracle/issues
I created an exe of my program that communicates with an oracle database using cx_Oracle to create excel sheets. If someone else uses this exe will they need Oracle installed?
Any computer that runs Python programs using cx_Oracle will need an 'Oracle client' installed. This is the set of Oracle libraries needed by cx_Oracle that allow connections to a database. The database can be on a remote computer. The Oracle client libraries are available in three different installs:
With the Oracle Database install
With a 'full' Oracle Client install
From Oracle Instant Client
The most common in your case would be to use Oracle Instant Client, which is relatively small and is simple to install.
You download the Instant Client 'Basic' package matching your operating system and the Python architecture (32 or 64 bit). Unzip it. Set your operating system search path such as PATH (on Windows) or LD_LIBRARY_PATH or ldconfig (on Linux) to the directory you unzipped.
Instant Client Downloads and instructions are at https://www.oracle.com/database/technologies/instant-client.html
cx_Oracle installation instructions are at https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html