[Solved] 64-bit Python calls 32-bit Oracle client error: Cx_Oracle.DatabaseError: DPI-1047

problem

The operating system is 64 bit Python and 32 bit Oracle client. For other reasons, the Oracle client cannot be changed to 64 bit, resulting in Cx_Oracle64 bit cannot be used, CX_Oracle32 bit cannot be installed.

reason

Under Windows environment, if 64 bit Python is installed, CX_Oracle is used, the 64 bit Oracle client is called by default. In this case, we can only install Cx_Oracle win_Amd 64-bit version.

Solution:

1. First install CX_Oracle matching the current Python version, my is Python 3.8. The installed version is: Cx_Oracle-8.3.0-cp38-cp38-win_amd64.whl

2. Download the relevant Oracle instantclient (instant client) and unzip it to a folder convenient for calling

Download address: https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html

The version I downloaded is: instantclient-basiclite-windows-x64-19.13.0.0.0dbru.Zip, you can try several times, there is always one for you

3. Unzip the instantclient and change the environment variable in the Python code to adjust the Oracle driver location.

My unzipped address is:

E:\software\Python\instantclient-basiclite-windows.x64-19.13.0.0.0dbru

The code adjustment method is

import os

os.environ[‘path’] =  r’E:\software\Python\instantclient-basiclite-windows.x64-19.13.0.0.0dbru\instantclient_19_13′

import cx_Oracle

Now CX_Oracle can call normally

Similar Posts: