2014-03-07 55 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项中所说的那样。 –