If you have installed Python, check your installed version of Python is the number of bits, as follows:
>> > import platform
>> > platform.architecture()
View digit version of the Oracle database:
SQL> select * from v$version;BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit
ProductionPL/SQL Release 11.2.0.4.0 - ProductionCORE
11.2.0.4.0 ProductionTNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production
Of course, your 64-bit operating system also can install 32-bit development environment. Not vice versa! Remember!
oracle client version, cx_Oracle version corresponds to the version of Python and digits, such as:
Python version: Python 3.5.1 64 place;
oracle client version: instantclient-basic-linux.x64-11.2.0.4.0.zip;
Select cx_Oracle-5.3 time to choose the 64-bit!
There are also three points Note:
Version corresponding to the number of bits are 64;
cx_Oracle python and corresponding version are 3.5.1;
cx_Oracle instantclient and corresponding version, is 11g;
Cx_Oracle on Linux installation process:
A: Installing python3
1. Prepare the build environment
yum groupinstall 'Development Tools'
yum install zlib-devel bzip2-devel openssl-devel ncurese-devel
yum -y install gcc python-devel
2. Download python3.5 package
wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz
3. Extract, compile
takes Jxvf Python 3.5.1.tar.xz
cd Python-3.5.1
./configure --prefix=/usr/local/python3
make && make install
Note here that this -prefix option to python3 installed in / usr / local / python3 catalog, but before the download archive and install packages it can be directly deleted
4. Replace the system default python version and pip
mv /usr/bin/python /usr/bin/python
2.6 point to establish a new soft link python3 and PIP 3
ln -s /usr/local/python3/bin/python3.5 /usr/bin/python
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
Two: Install the oracle client tools instantclient-basic-linux.x64-11.2.0.4.0.zip
Download: https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
Direct download zip package, extract to!
1, the establishment of oracle installation directory;
[root@dev-bibaobiao-04 ~]# mkdir -p /data/oracle
2, the installation package into instantclient-basic-linux.x64-11.2.0.4.0.zip / data / oracle / down, and then decompress
[root@dev-bibaobiao-04 oracle]# unzip instantclient-basic-linux.x64-11.2.0.4.0.zip
Generating directory: / data / oracle / instantclient_11_23
3, configure the environment variables: / ect / profile file or /root/.bash_profile
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export ORACLE_IC_HOME=/data/oracle/instantclient_11_2
export ORACLE_HOME=$ORACLE_IC_HOME
export TNS_ADMIN=$ORACLE_IC_HOME
export PATH=$PATH:$HOME/bin:$ORACLE_IC_HOME
export LD_LIBRARY_PATH=$ORACLE_IC_HOME:/usr/lib
Three: Installation cx_Oracle plug
[root@tool202 bin]# pip install cx_Oracle
Or in order to prevent errors, you can choose to download the corresponding version:
https://pypi.org/project/cx_Oracle/5.3/#files
[root@tool202 python]# tar -zxvf cx_Oracle-5.3.tar.gz
[root@tool202 cx_Oracle-5.3]# python setup.py install