Article From:


python3.6.3Download address: WGet

After decompression, go to the decompressed directory, install directly:

Modify the temporary language first:

export LANG=zh_CN.UTF-8


./configure –prefix=/usr/local/python3.6.3 –with-ssl

make && make install

Python: with a backup system

mv /usr/bin/python /usr/bin/pythonbak

Create a new Python soft link:

ln -s /usr/local/python3.6.3/bin/python3.6 /usr/bin/python

Modify the yum configuration file to prevent Yum from being unavailable

Change the head of the file to /usr/bin/python! /usr/bin/python2.6. save and exit.



Install cx_oracle (using PIP3 installation)

The cx_Oralce module that installs Python needs to rely on Oracle Instant Client:

Download instantclient_12_2 link: password: mdln

Alternate address:

mkdir -p /u01/install && mv /tmp/instantclient_12_2 /u01/install (/u01/installThis path is optional, not necessarily the same as mine.

Modify the environment variable:

vim /etc/profile.d/

export ORACLE_HOME=/u01/install/instantclient_12_2

The environment variable takes effect source /etc/profile.d/


a:Installation of direct production environment

cd /usr/local/python3.6.3/bin/

./pip3 install cx_oracle


b:Create a virtual environment for python3 (isolation from Python installed under the system)

 python3 -m venv /opt/py3
source /opt/py3/bin/activate 
Install cx_oracle
pip3 install cx_oracle


What problems do you encounter in the chart, please do Baidu yourself. It is not very difficult. Yum is installed with some dependencies.

 A template is attached.

 import cx_Oracle

class Oracle_Helper(object):

    def __init__(self):
        self.db_url = “”
        self.db_username = “user”
        self.db_userpassword = “pwd”

    def open(self):
        self.conn = cx_Oracle.connect(self.db_username, self.db_userpassword, self.db_url)
        self.c = self.conn.cursor()

    def run(self, sql):
        sql = sql
        x = self.c.execute(sql)
        data = x.fetchall()
        return data

def close(self):

    def __enter__(self):
        return self

    def __exit__(self, exc_type, exc_val, exc_tb):

Leave a Reply

Your email address will not be published. Required fields are marked *