简体   繁体   中英

cx_Oracle imports wrong module

I am trying to connect to an Oracle DB v.9. I downloaded latest Instant Client (12.1.0.2.0) + SDK, then cx_Oracle. When trying to connect to the DB it says

cx_Oracle.DatabaseError: ORA-03134: Connections to this server version are no longer supported.

so I tried installing an older version of Instant Client 10.2.0.5:

sudo yum remove oracle-instantclient12.1-basic
sudo yum install /vagrant/oracle-instantclient-devel-10.2.0.5-1.x86_64.rpm

and updated my env:

export ORACLE_HOME=/usr/lib/oracle/10.2.0.5/client64/
export LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.5/client64/lib/

but when I try to run my Python script, cx_Oracle says:

ImportError: libclntsh.so.12.1: cannot open shared object file: No such file or directory

Of course there's no such file or directory: I have version 10.2.0.5, not 12.1. And my file is called libclntsh.so.10.1 , not libclntsh.so.12.1 . How do I make cx_Oracle import the right file? Or is there a way to make Instant Client v.12 work with server v.9?

Oracle guarantees backwards compatibility for two versions. So Version 10 can access version 8, 9, 10. Version 12 can only access version 10 and up.

You need to do a clean install of the correct client.

The cx_Oracle you compiled or installed was built against Oracle 12.1. You will need to build one against Oracle 10.2 instead. If you make sure that the old instant client is removed and the new one is in place, you can simply run pip install cx_Oracle. Versions 5.2 and up of cx_Oracle now are able to locate the instant client and compile against it without additional help. Note that you need to make sure that you have the instantclient-devel package installed for that to work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM