一、创建所需目录
mkdir -p /home/用户名/software/python3.6.1
mkdir -p /home/用户名/priv/byd
mkdir -p /home/用户名/priv/byd/src/python
mkdir -p /home/用户名/priv/byd/org
二、修改byd目录的权限
cd /home/用户名/priv/
ll
chmod 777 byd/
ll
三、将安装包放到byd中,并将包备份到org中
在byd中解包:
cd /home/用户名/priv/byd
tar zxvf Python-3.6.1.tgz
tar zxvf cx_Oracle-6.0.2.tar.gz
四、安装python-3.6.1(如果在make编译报错字符集错误,可以暂时将LANG修改为C待成功安装成功后再改回来)
env | grep LANG
ls
cd Python-3.6.1
配置:
./configure --prefix=/home/用户名/software/python3.6.1
编译:
make
安装:
make install
五、配置环境变量
vi /home/用户名/.bashrc
# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
# User specific aliases and functions
#add bash execut command's time
#export HISTTIMEFORMAT='%F %T 命令: '
export PATH=$PATH:/home/用户名/software/python3.6.1/bin
wq
source /home/用户名/.bashrc
env | grep PATH
六、安装cx_Oracle
cd /home/用户名/priv/byd/
ls
cd cx_Oracle-6.0.2
ls
安装:
python3 setup.py install
source /home/monitor/.bashrc
env | grep PATH
python3
env | grep LANG
----LANG=zh_CN.GB18030
测试脚本
cd src/python/
vi connora.py
#!/home/用户名/software/python3.6.1/bin/python3
import os,sys
import cx_Oracle
db=cx_Oracle.connect('monitor/monitor@21.0.129.73/flrdb')
csr=db.cursor()
sql='select * from flr.flr_clr_date_desc'
csr.execute(sql)
rslt=csr.fetchall()
print ( "All Result is:%s" % rslt )
csr.close()
db.close()
wq
python3 connora.py
python3
env | grep CPDS
网友评论