oracle / python-cx_Oracle

Python interface to Oracle Database now superseded by python-oracledb
https://oracle.github.io/python-cx_Oracle
Other
887 stars 361 forks source link

DatabaseError: DPI-1050: Oracle Client library is at version 0.0 but version 11.2 or higher is needed #351

Closed TMCG123 closed 5 years ago

TMCG123 commented 5 years ago

DatabaseError: DPI-1050: Oracle Client library is at version 0.0 but version 11.2 or higher is needed

I get this message when trying to access Oracle's Instant Client with Spyder3 on Windows 7. This is my first attempt at accessing a cloud oracle database using Python.

Below follows a description of my system:

I am running Python 3.7.2 installed with Anaconda - 64 bit

I import cx_Oracle into the script file.

I downloaded Oracle Basic Light version v6.2 (64bit) for Windows to: C:\oracle\instantclient_19_3 This path I set to the environment variable: CloudOracleDB

I downloaded the 'wallet' to C:\oracle\instantclient_19_3 \network\admin This path I set to the environment variable: TNS_ADMIN

My Windows path looks like this: %sSystemRoot%;%SystemRoot%;%CloudOracleDB%;%TNS_ADMIN%;\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Microsoft Windows Performance Toolkit\

What have I done to fix this myself ?

I have double checked the 64 bit compatibility between Oracle Instant Client and Python.

I have rebooted my PC.

I have read posts on the web in general related to this problem and have tried to follow the path set up requirements.

Could anyone point me in the right direction ?

Tim

cjbj commented 5 years ago

When exactly does the error occur? Do some basic queries work? What does your connect call look like?

Typically DPI-1050 will be thrown if you try to use a feature that isn't support with your combination of Oracle client libraries and the Oracle DB. Are you sure you don't have any old Oracle libraries on your machine, for example in one of the %SystemRoot% or system32 directories?

Remove TNS_ADMIN from PATH. It doesn't contain binaries or libraries. In fact, you don't need to set the environment variable at all because C:\oracle\instantclient_19_3 \network\admin is a default location that will be used without needing TNS_ADMIN set.

What's your cx_Oracle version?

Checking the bit-ness and rebooting were good things to do.

Some terminology isn't quite right:

when trying to access Oracle's Instant Client with Spyder3

It's cx_Oracle that uses Instant Client. You don't access it yourself.

And:

Oracle Basic Light version v6.2 (64bit)

There is no such version; you appear to have 19.3.

TMCG123 commented 5 years ago

[ %SystemRoot%.txt system32.txt

](url) I get it that cx_Oracle and the Instant Client Libraries together connect the database.

Below follows my answers to your questions followed by a few futher points which may be relevant.

I have also attached two text file. These contain a list of the files in %SystemRoot% and system32.

I think these lists are important.

When exactly does the error occur?

When I run the python script to connect to the database.

The only instructions are to create a connection.

Do some basic queries work?

I haven’t got to querying the database yet.

What does your connect call look like?

"adb.eu-zurich-1.oraclecloud.com:1522/fzpyay7romd3t8w_db201909010833_tp.atp.oraclecloud.com" This connection string was provided by Oracle.

Any old Oracle libraries on your machine?

I don’t recognise any entry in either c:\Windows or c:\Windows\System32

I have attached the two lists as text files as I think this check is very important.

I have removed TNS_ADMIN and C:\oracle\instantclient_19_3\network\admin from the envoronment variables settings.

The environment path now reads:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Microsoft Windows Performance Toolkit\

I have placed the Oracle client libraries in instantclient_19_3 and the wallet in admin. These are on the path: C:\oracle\instantclient_19_3\network\admin.

What's your cx_Oracle version?

cx-Oracle 7.2.2

anthony-tuininga commented 5 years ago

Perform a search for OCI.DLL everywhere on your system. If I remember correctly, the command is:

dir /s OCI.DLL

Perform that command in the root of your C: drive.

TMCG123 commented 5 years ago

oci.dll (lower-case) is in C:\Oracle\instantclient_19_3

cjbj commented 5 years ago

dll (lower-case) is in C:\Oracle\instantclient_19_3

Does it occur on any other disks?

You said

These are on the path: C:\oracle\instantclient_19_3\network\admin.

(i) I don't see it in your PATH? (ii) the directory that should be in PATH is C:\oracle\instantclient_19_3

The environment path now reads: %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Microsoft Windows Performance Toolkit\

Try adding C:\oracle\instantclient_19_3 as the first entry on PATH.

Is Spyder3 picking up your PATH? You may need to reboot/restart after setting PATH. Or you may need to configure Spyder3 in some other way to set PATH so it knows about Instant Client.

TMCG123 commented 5 years ago

I am miss-using terminology again.

I said I had placed the Oracle client libraries and the 'wallet' on the PATH. What I was trying to say was that these files are in a particular directory. For the record I think this misuse of terminology is due to not understanding the significance of the PATH in Windows. This is particularly so when PATH is referred to in terms of PYTHON and when it is referred to generally in the context of environment variables.

The directory that should be in PATH is C:\oracle\instantclient_19_3

This has now been done.

dir /s OCI.DLL

This command shows that OCI.DLL is in two locations:

C:\$Recycle.Bin\S-1-5-21-3633130985-3880167189-3917744553-1000\$R... C:\oracle\instantclient_19_3

Is Spyder3 picking up your PATH?

Thanks to a previous related post on the site I have been able to force Spyder3 to put C:\oracle\instantclient_19_3 at the beginning of the PATH. os.environ['PATH'] = LOCATION + ';' + os.environ['PATH'] Regarding this Python code, ';' was originally '+'.

cjbj commented 5 years ago

So, is your problem solved?

TMCG123 commented 5 years ago

Well I think I should remove C:$Recycle.Bin\S-1-5-21-3633130985-3880167189-3917744553-1000$R...

Is that right ?

TMCG123 commented 5 years ago

OK so I have deleted the oci.dll from C:$Recycle.Bin... On re-running the same Python script I get the error message: DPI-1050: Oracle Client library is at version 0.0 but version 11.2 or higher is needed

TMCG123 commented 5 years ago

For the moment I shall continue with sqlite3. Thanks for all the offers to help.

anthony-tuininga commented 5 years ago

That error message indicates that you have another copy of the OCI.DLL with a version earlier than 11.2 somewhere on your system. Verify that all copies on all drives (that you don't want) have been removed and that you have rebooted your machine.

Pythonmaster001 commented 5 years ago

Just solved same issue. I tried to run directly exe file in folder C:\Oracle\instantclient_19_3 outside Python application. No issue with C:\Oracle\instantclient_18_5 installed from instantclient-basic-windows.x64-18.5.0.0.0dbru

cjbj commented 5 years ago

@Pythonmaster001 can you explain a bit more? What exe did you try to run? What was the difference between 19 & 18 instant client?

L-NiNo commented 5 years ago

I came across this trying to get node_oracledb to work. Downgrading to instant client 18.5 also worked on my PC.

cjbj commented 5 years ago

@L-NiNo Please explain more. When did you see this error? At connection or later?

L-NiNo commented 5 years ago

@cjbj I believe it was at connection. It was a new v19 install of instant client, and PATH was correct and rebooted. Got this error when running the script. Found this post, I deleted v19 for v18.5, adjusted PATH accordingly, restarted, and then this error was gone. ¯_(ツ)_/¯

L-NiNo commented 5 years ago

@cjbj - I looked into it a little more from my end and set up. I believe this issues was the Redistributable installed on my PC. I only had 2013/2012 redistributables installed. The oracle doc shows a 2017 is needed for v19. I am sure this is why v18 worked and v19 didn't. I hope this helps someone else out.

https://oracle.github.io/node-oracledb/INSTALL.html#--366-install-the-visual-studio-redistributables The PATH variable needs to include the appropriate VS Redistributable: Oracle client 19 requires the Visual Studio 2017 Redistributable. Oracle client 18 and 12.2 require the Visual Studio 2013 Redistributable. ...

cjbj commented 5 years ago

@L-NiNo that's great info. Did you re-test with 19c?

cjbj commented 4 years ago

Another potential cause is trying to use 19c Oracle client libraries on WIndows 7. This combination will fail. The supported list for 19c is in: Operating System Checklist for Oracle Database Client Installation

prbrganguly commented 2 years ago

I installed oracle server instead oracle instant client and oracle_fdw is installed but at the time of CREATE EXTENSION oracle_fdw; at postgresql showing error "ERROR: could not load library "C:/Program Files/PostgreSQL/14/lib/oracle_fdw.dll": The specified procedure could not be found."

cjbj commented 2 years ago

@prbrganguly you appear to have updated the wrong issue. This issue is long closed, and is not about postgres or FDW. Can you re ask in a better repo?