Python2.6 Cx_Oracle Linux下编译安装

 

分类: python Oracle 239人阅读 评论(0) 收藏 举报
(一) Python 2.6 安装 1.下载Python2.6.X 版本的源码包,这里采用平台编译安装。   Python-2.6.4.tar.bz2 2.解压缩 ,使用J参数解压bigz2类型的压缩文件   tar  -jxvf Python-2.6.4.tar.bz2   cd  Python-2.6.4 3. 配置编译参数   注意: 加上 –enable-shared 参数,否则不会生成libpython2.6.so.1.0的动态链接库,不加默认生成libpython2.6.so.a的静态链接库   ./configure –enable-shared 4. 编译   Make 5. 安装(需高权账号,具有/usr/local的写权限)   Make install 6.检查   输入Python 命令,如出现Cannot Open Shared lib 等问题,说明没有成功加载动态链接库,需手动加入环境变量。   因为python的lib被系统默认安装在/usr/local/lib/,所以在~/.bash_profile中加入环境变量 LD_LIBRARY_PATH   Vi ~/.bash_profile   插入行   export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH   保存 执行~/.bash_profile以导入环境变量   再次执行 python  正常进入 Python 2.6 Shell (二)  cx_Oracle安装
1.  确保安装Oracle 客户端,或者服务器已经安装Oracle DataBase 2.  设置环境变量   VI ~/.bash_profile   插入行 export  ORACLE_HOME=/*****Oracle Install Dir****/Instance_Client      export  LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/local/lib   保存   执行~/.bash_profile以导入环境变量 3.  下载 cx_Oracle 源码包 cx_Oracle-5.0.4.tar.gz 4.  解压缩   tar –zxvf cx_Oracle-5.0.4.tar.gz   cd  cx_Oracle-5.0.4 5.  编译   python  setup.py build 6.  安装   python setup.py install   如出现copying build/lib.linux-i686-2.6-10g/cx_Oracle.so -> /usr/local/lib/python2.6/site-packages 表示cx_Oracle包已经被拷贝至Python的sys路径中 7. 检查

 

代码
复制代码
[oracle @ crmdevpdb ~] $ python Python 2.6 . 4 (r264: 75706 , Dec 20 2010 , 20 : 13 : 54 ) [GCC 4.1 . 2 20070626 (Red Hat 4.1 . 2 - 14 )] on linux2 Type " help " , " copyright " , " credits " or " license " for more information. >>> import cx_Oracle as oracle >>> con = oracle.connect( " SIEBEL/SIEBEL@DEVP " ) >>> cur = con.cursor() >>> cur.execute( " select * from s_party " ) <__builtin__.OracleCursor on <cx_Oracle.Connection to SIEBEL @ DEVP >> >>> res = cur.fetchone() >>> for i in res: ...     print i ... 1 - 3SFF 2010 - 02 - 01 16 : 32 : 09 1 - J6N 2010 - 02 - 01 16 : 51 : 47 1 - J6N 2 0 Organization 1 - 3SFF Y 2010 - 02 - 01 16 : 52 : 41 User Organization ? 2 None >>>
复制代码

 

转载于:https://www.cnblogs.com/wuxi/archive/2013/01/06/2847628.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值