Python匯入cx_Oracle報錯

來源:互聯網
上載者:User

標籤:

系統內容:RHEL5.4   python2.5(手動編譯安裝,系統帶有2.4版本)

在使用python指令碼訪問資料庫時,需要匯入cx_Oracle模組    

$>>>import cx_OracleTraceback (most recent call last):  File "/ghca/monitor/async_Msg_MQDis/run.py", line 2, in <module>    import async_Msg_MQDis  File "/ghca/monitor/async_Msg_MQDis/async_Msg_MQDis.py", line 1, in <module>    import cx_OracleImportError: No module named cx_Oracle分析原因:1、懷疑缺少模組包[[email protected] async_Msg_MQDis]$ rpm -qa|grep cxcx_Oracle-5.1.2-1發現已安裝,查詢包安裝目錄[[email protected] async_Msg_MQDis]$ rpm -ql cx_Oracle-5.1.2-1|less/usr/lib64/python2.4/site-packages/cx_Oracle.so/usr/share/doc/cx_Oracle-5.1.22、切換到模組目錄下進行匯入$cd /usr/lib64/python2.4/site-packages[[email protected] site-packages]$ pythonPython 2.5.2 (r252:60911, Apr 11 2013, 14:10:12) [GCC 4.1.2 20080704 (Red Hat 4.1.2-46)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import cx_OracleTraceback (most recent call last):  File "<stdin>", line 1, in <module>ImportError: ./cx_Oracle.so: undefined symbol: PyUnicodeUCS4_Decode>>> 3、猜測可能是python版本與cx_Oracle對應版本不一致匯入[[email protected] ~]$ ls /usr/bin/python2.4 /usr/bin/python2.4[[email protected] ~]$ /usr/bin/python2.4Python 2.4.3 (#1, Jun 11 2009, 14:09:37) [GCC 4.1.2 20080704 (Red Hat 4.1.2-44)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> import cx_Oracle>>> 匯入成功總結:中途也曾重新下載cx_Oracle-5.1.2-10g-py25-1.i386.rpm和cx_Oracle-5.1.2-10g-py25-1.x86_64.rpm進行嘗試,均未匯入成功,並且在安裝了cx_Oracle*py25*.x86_64.rpm版本進行匯入時報缺少“libpython2.5.so.1.0”庫檔案錯誤。在公司測試機上裝有python2.6,其中 /usr/lib/libpython2.6.so.1.0 庫檔案屬於python-libs-2.6.6-20.el6.i686包。

Python匯入cx_Oracle報錯

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.