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 202010, 20:13:54) [GCC 4.1.220070626 (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-0116:32:091-J6N 2010-02-0116:51:471-J6N 20 Organization 1-3SFF Y 2010-02-0116:52:41 User Organization ?2 None >>>
复制代码

 

posted @ 2013-01-06 14:14  wuxi812  阅读(687)  评论(0编辑  收藏  举报