cx_Oracle:distutils.errors.DistutilsSetupError:找不到Oracle包含文件

khr*_*ris 20 linux oracle cx-oracle python-2.5

我需要在Linux上安装cx_Oracle for Python 2.5(Linux 2.6.18-371.1.2.el5 i686).我已经安装了Oracle客户端10.2.0.4.

我试过以下:1.cx_Oracle tar.gz从下载http://sourceforge.net/projects/cx-oracle/files/.我不知道哪个列出的版本适用于python 2.5和Oracle客户端10.2.0.4,所以请尝试cx_Oracle-5.1.tar.gz.解压缩tar,转到解压缩文件夹并运行python setup.py install.我收到了错误:

Traceback (most recent call last):
File "setup.py", line 187, in <module>
raise DistutilsSetupError("cannot locate Oracle include files")
distutils.errors.DistutilsSetupError: cannot locate Oracle include files
Run Code Online (Sandbox Code Playgroud)

在.bash_profile中我设置了oracle路径:

export ORACLE_HOME=/usr/oracle/10.2.0.4/client
export PATH=$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
Run Code Online (Sandbox Code Playgroud)

如何解决这样的错误,也许我需要另一个版本的cx_Oracle tar?

  1. 运行pip install cx_Oracle.得到错误:

下载/解压缩cx-Oracle

Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement cx-Oracle
No distributions at all found for cx-Oracle
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我正确的解决方案吗?

更新 建议响应后我得到以下错误:

...
cx_Oracle.c:496: warning: passing argument 3 of âPyModule_AddIntConstantâ makes integer from  pointer without a cast
cx_Oracle.c:497: error: âOCI_UCBTYPE_EXITâ undeclared (first use in this function)
cx_Oracle.c:497: warning: passing argument 3 of âPyModule_AddIntConstantâ makes integer from pointer without a cast
cx_Oracle.c:498: error: âOCI_UCBTYPE_REPLACEâ undeclared (first use in this function)
cx_Oracle.c:498: warning: passing argument 3 of âPyModule_AddIntConstantâ makes integer from pointer without a cast
error: command 'gcc' failed with exit status 1
Run Code Online (Sandbox Code Playgroud)

fn.*_*fn. 14

当您运行setup.py时,它将检查ORACLE_HOME上的任何这些文件夹.

possibleIncludeDirs = ["rdbms/demo", "rdbms/public", "network/public",
        "sdk/include"]
Run Code Online (Sandbox Code Playgroud)

此外,即使客户端有时将包含文件(例如oci.h)放在/ usr/include/oracle //客户端中,如果ORACLE_HOME下没有"include"目录,也会创建一个符号链接.

sudo ln -s /usr/include/oracle/11.2/client $ORACLE_HOME/include
Run Code Online (Sandbox Code Playgroud)

看起来你错过了Client SDK