2014-03-07 53 views
0

我需要使用Python連接到Oracle數據庫。所以,我做了以下幾點:無法獲得的Python 3.2.5和cx_Oracle工作

  1. 我從Oracle網站下載了instantclient_11_2 basic和sdk。
  2. 把文件上的/ opt/ORA/instantclient
  3. 出口ORACLE_HOME = /選擇/ ORA/instantclient
  4. 出口LD_LIBRARY_PATH = $ LD_LIBRARY_PATH:$ ORACLE_HOME
  5. CD $ ORACLE_HOME & & LN -s libclntsh.so .11.1 libclntsh.so
  6. 下載並安裝cx_Oracle-5.1.1-11g-py32-1.x86_64.rpm

但是,當我試圖運行import cx_Oracle我得到這個錯誤:

ImportError: No module named cx_Oracle 

根據cx_Oracle site我需要將文件cx_Oracle.pyd或cx_Oracle.so放在您的Python路徑的任何位置。但我安裝cx_Oracle-5.1.1-11g-py32-1.x86_64.rpm後找不到這些文件..

順便說一下,我也嘗試使用壓縮版本進行安裝,但是我得到了很多錯誤建設像error: command 'gcc' failed with exit status 1

有什麼我做錯了什麼?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

找到了解決的人。我升級我的蟒蛇到最新的,使用cx_Oracle的python33和instantclient11.2 ..

+0

什麼是你的OS/Linux和版本? – shimofuri

+0

我在RHEL5上...... –

回答

1

1:對於你的失敗建築物,請提供更多的細節。可能是因爲您沒有安裝python開發包(「python-devel」)

2:您還需要安裝Oracle客戶端,因爲cx_Oracle只是Python與Oracle客戶端之間的鏈接器。快速的方法是獲得「即時客戶端」。

cx-oracle's README

Please note that an Oracle client (or server) installation is required in order to use cx_Oracle. If you do not require the tools that come with a full client installation, it is recommended to install the Instant Client which is far easier to install.

+0

我不知道python3.x是否有「python-devel」。 IO不能罰款。我已經有了「即時客戶端」,就像我在第1項中所說的那樣。 –