http://blog.csdn.net/LIUYANG007/archive/2007/03/16/1531167.aspx
開始在ubuntu下用python調用oracle,決定使用cx_Oracle.
安裝前要確定oracle安裝成功并能正常使用
在cx_Oracle的網站上http://www.python.net/crew/atuining/cx_Oracle/
有windows和linux 2種安裝版本
按照自己的具體配置選擇下載版本,我是oracle10,python 2.4
下載Fedora Core 5 RPM (Oracle 10g, Python 2.4),
cx_Oracle-4.3-10g-py24-1.i386.rpm
先把rpm轉換成deb安裝
suod alien cx_Oracle-4.3-10g-py24-1.i386.rpm cx_Oracle-4.3-10g-py24-1.i386.deb
再安裝deb
sudo dpkg -i cx_Oracle-4.3-10g-py24-1.i386.deb
安裝完成后在python里輸入
>>> import cx_Oracle
Traceback (most recent call last):
File "", line 1, in ?
ImportError: libclntsh.so.10.1: cannot open shared object file: No such file or directory
經過查找發現是oracle的路徑沒有設置
輸入:
locate libclntsh.so.10.1
獲取對于路徑
/app/oracle/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1
編輯/etc/ld.so.conf
sudo gedit /etc/ld.so.conf
在最后一行輸入獲取的路徑
/app/oracle/oracle/product/10.2.0/db_1/lib/
保存,關閉gedit
執行
ldconfig
再調用就好了
本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/LIUYANG007/archive/2007/03/16/1531167.aspx