Python2.6 Cx_Oracle Linux下编译安装
生活随笔
收集整理的這篇文章主要介紹了
Python2.6 Cx_Oracle Linux下编译安装
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?
分類: python Oracle 2012-06-07 00:04 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 >>>?
轉載于:https://www.cnblogs.com/wuxi/archive/2013/01/06/2847628.html
總結
以上是生活随笔為你收集整理的Python2.6 Cx_Oracle Linux下编译安装的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: WMI 使用教程_.NET 入门教程
- 下一篇: WEB效能测试和负载测试部分截图