Install cx_Oracle in Python source code

Source: Internet
Author: User

Recently, I contacted the monitoring platform Zenoss, which involves the Oracle plug-in ZenPacks. community. OracleMon. To use this plug-in, you must install Python cx_Oracle. Next, let's talk about how to install it.

1. software packages involved

1. cx_Oracle

: Http://sourceforge.net/projects/cx-oracle/files? Source = navbar

I download the latest version of cx_oracle-5.1.2.tar.gz.

2. Oracle_client

To use cx_Oracle, you must install Oracle_client, or you have installed an Oracle database.

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

To connect to Oracle11 as an example, you need to download the following rpm package:

Oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm

Oracle-instantclient11.2-jdbc-11.2.0.4.0-1.x86_64.rpm

Oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm

Oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm

Oracle-instantclient11.2-odbc-11.2.0.4.0-1.x86_64.rpm

Oracle-instantclient11.2-tools-11.2.0.4.0-1.x86_64.rpm

After the software packages are downloaded, we will start to install them.

Ii. Source Code Installation

1. Oracle_client installation:

# Rpm-ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-jdbc-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-odbc-11.2.0.4.0-1.x86_64.rpm oracle-instantclient11.2-tools-11.2.0.4.0-1.x86_64.rpm
# Echo/usr/lib/oracle/11.2/client64/lib/>/etc/ld. so. conf
# Ldconfig

If ldconfig is not configured, the following error is reported when running cx_Oracle:

Libclntsh. so.11.1: cannot open shared object file: No such file or directory

2. Set the user's environment variables:

Here, you need to describe which account you use to install cx_Oracle and which account's environment variables need to be configured. The following example uses the root account as an example;

If you do not configure the environment variables or the environment variables are incorrectly configured, various errors will be reported when you install cx_Oracle, such:

Oci. h: No such file or directory

# Vi ~ /. Bashrc

Export TNS_ADMIN = "/usr/lib/oracle"
Export ORACLE_HOME = "/usr/lib/oracle/11.2/client64"
Export LD_LIBRARY_PATH = "$ {LD_LIBRARY_PATH }:: {ORACLE_HOME}/lib"
Export PATH = "$ {PATH }:$ {ORACLE_HOME }"

# Source ~ /. Bashrc

3. Source Code Installation

# Tar-zxvf cx_Oracle-5.1.2.tar.gz
# Cd cx_Oracle-5.1.2
# Python setup. py install

4. Check after successful installation

# Python
Python 2.7.2 (default, Aug 21 2013, 12:12:55)
[GCC 4.4.4 20100726 (Red Hat 4.4.4-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

>>> Import cx_Oracle
>>>

CentOS install Python 2.6.5 & cx_Oracle

Problems encountered during installation of the cx_Oracle module in Python and Solutions

Python + cx_Oracle installation and a simple example (archive hot backup data files)

Python development technology details. (Zhou Wei, Zong Jie). [hd PDF scan version + book guide video + code]

Obtain Linux information using a Python script

Python details: click here
Python: click here

Related Article

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.