Linux installation Cx_oracles

Source: Internet
Author: User

Linux installation Cx_oracles

Environmental background

System: CentOS6.8

Python:python 2.7.13 | Anaconda 4.3.1 (64-bit)

Cx_oracle module: 5.0.4

Oracle:11.2.0.1.0

Oracle Client: 11.2.0.1.0

1. Download

Http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

Download the following two files from the download link

Oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.zip instantclient-sdk-linux.x64-11.2.0.1.0.zip# Note here to depend on the version of the connection database, the installation of the client must choose the base version, do not choose Instantclient11.2-basiclite


Unzip these two files into the/opt/instantclient_11_2 directory

2. Setting Environment variables

# vim/etc/profile #文件尾部添加export oracle_home=/opt/instantclient_11_2/export ld_library_path= $LD _library_path:$ oracle_home# Source/etc/profile

3, Installation Cx_oracle

Before installing cx_oracle, you need to establish a link libclntsh.so, as follows:

Cd/opt/instantclient_11_2/ln-s libclntsh.so.11.1 libclntsh.so

Download cx_oracle

https://sourceforge.net/projects/cx-oracle/files/5.0.4/

# tar-xf cx_oracle-5.0.4.tar.gz# cd cx_oracle-5.0.4# python setup.py install

Test:

>>> Import Cx_oracle/root/.pyenv/versions/anaconda2-4.3.1/lib/python2.7/site-packages/cx_ Oracle-5.0.4-py2.7-linux-x86_64.egg/cx_oracle.py:3: Userwarning:module cx_oracle was already imported from/root/. Pyenv/versions/anaconda2-4.3.1/lib/python2.7/site-packages/cx_oracle-5.0.4-py2.7-linux-x86_64.egg/cx_ ORACLE.PYC, but/opt/cx_oracle-5.0.4 is being added to sys.path>>>>>> print cx_oracle.version5.0.4

4. Test database connection

>>> import cx_oracle as cx>>> db=cx.connect (' Finchina/[email protected]/orcl ') >>> print Db.version11.2.0.1.0>>> Db.close ()

FAQ collation:

Question 1:conn0=cx.connect (' Finchina/[email protected]:1521/orcl ')

Cx_Oracle.InterfaceError:Unable to acquire Oracle environment handle

Solution: Make sure that the instantclient you install is the same as the version of the database you need to connect to. Download

Oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.zip Instantclient-sdk-linux.x64-11.2.0.1.0.zipwindows This issue occurs copy all the. dll files under the client to the Python installation package site_pageages directory

You can then configure it as described above.

Question 2:conn0=cx.connect (' Finchina/[email protected]:1521/orcl ')

Cx_oracle.databaseerror:ora-28547:connection to server failed, probable Oracle Net admin error

Solution:

Reinstall cx_oracle5.0.4

Re-install Instantclient11.2-basic

The following excerpt from the Oracle client:http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html

instant client package - basic: all files required to run  oci, occi, and jdbc-oci applications# Notes: Instant Client Package  -  Basic: Run OCI, All files required for Occi and JDBC-OCI applications oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.zip  (48,338,185 bytes)   (cksum - 15985569) oracle-instantclient11.2-basic-11.2.0.1.0-1.x86_64.rpm  (47,811,007  bytes)   (cksum - 4244105838) Instant client package - basic light:  Smaller version of the Basic, with only English error  messages and unicode, ascii, and western european character set  support# Notes: Instant Client Package  -  Basic lightweight: Smaller version of basic, only English error messages and Unicode,ascii and Western European character set support, Assi! , it turned out to be a character set problem oracle-instantclient11.2-basiclite-11.2.0.1.0-1.x86_64.zip  (20,825,489 bytes)   (cksum  - 133027975) oracle-instantclient11.2-basiclite-11.2.0.1.0-1.x86_64.rpm  (20,649,392 bytes)   (cksum - 1121446971) 

Summarize:

The problem is very serious, encounter problems, random Baidu, no idea of Google, but slow to solve the problem rhythm. I hope that after this time, encounter any problems can: clear ideas, split the problem, and then one by one break

Issue 3:importerror:libclntsh.so.11.1:cannot open Shared object file:no such file or directory

Solution:

CD/OPT/INSTANTCLIENT_11_2LN-SV libclntsh.so.11.1 libclntsh.so


This article from "Ljohn" blog, declined reprint!

Linux installation Cx_oracles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.