0

I have an error when I try to connect to an Oracle database in version 10. I use oracledb as a module. The error :

oracledb.init_oracle_client(lib_dir="64Bit121")
  File "src\oracledb\impl/thick/utils.pyx", line 455, in oracledb.thick_impl.init_oracle_client
  File "src\oracledb\impl/thick/utils.pyx", line 479, in oracledb.thick_impl.init_oracle_client
  File "src\oracledb\impl/thick/utils.pyx", line 400, in oracledb.thick_impl._raise_from_info
oracledb.exceptions.DatabaseError: DPI-1047: Cannot locate a 64-bit Oracle Client library: "The specified module could not be found"

And the code :

import oracledb

oracledb.init_oracle_client(lib_dir="64Bit121")
with oracledb.connect(user="etusae1",password="***",host="162.38.222.149", port=1521, sid="iut") as connection:
    with connection.cursor() as cursor:
        sql = """select sysdate from dual"""
        for r in cursor.execute(sql) :
            print(r)

I tried several different clients (version 11.2 in 64 and 32 and also version 12.1 in 64bit) After hours of research I still do not understand why I have this error (I obviously hide my password and my login)

Kyucraft
  • 1
  • 1

1 Answers1

1

First, have you tried with thin mode? Just comment out the line that calls init_oracle_client() and try again.

Second, if you need thick mode, the value supplied to init_oracle_client() for the lib_dir parameter should be an absolute path. Try changing that. You can also follow the documentation and set the environment variable DPI_DEBUG_LEVEL to the value 64 to see what is happening.

Anthony Tuininga
  • 6,388
  • 2
  • 14
  • 23
  • Thanks a lot, with the absolute path, it works. But no solution exists to not need the absolute path ? – Kyucraft Mar 14 '23 at 15:24
  • Technically you can use a relative directory but it has to be relative to something not easily in your control. Typically the DPI-1047 will show you what actual directories were tried, or you can set DPI_DEBUG_LEVEL to 64 as mentioned above. This may help. But overall I recommend using an absolute directory. You can try Python functions to find where your script is being run from, e.g. like `oracledb.init_oracle_client(lib_dir=os.getcwd()+'/instantclient_19_8')` (though this snippet is relative to where you invoked Python from). Maybe try using `os.path.dirname(os.path.realpath(__file__))` – Christopher Jones Mar 15 '23 at 01:37