cx_Oracle:distutils.errors.DistutilsSetupError:无法找到Oracle包含文件 [英] cx_Oracle: distutils.errors.DistutilsSetupError: cannot locate Oracle include files

查看:563
本文介绍了cx_Oracle:distutils.errors.DistutilsSetupError:无法找到Oracle包含文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need install cx_Oracle for Python 2.5 on Linux (Linux 2.6.18-371.1.2.el5 i686). I have installed Oracle client 10.2.0.4.

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

I have tried following: 1. Download cx_Oracle tar.gz from http://sourceforge.net/projects/cx-oracle/files/. I don't know which of listed version are suitable for python 2.5 and Oracle client 10.2.0.4, so try cx_Oracle-5.1.tar.gz. Unpacked tar, go to unpacked folder and run python setup.py install. I got error:

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

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

In .bash_profile I have setted oracle path:

export ORACLE_HOME=/usr/oracle/10.2.0.4/client
export PATH=$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

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

How fix such error, maybe I need another version of cx_Oracle tar?

  1. 运行pip install cx_Oracle.出现错误:

下载/解压缩cx-Oracle

Downloading/unpacking 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

有人可以建议我正确的解决方案吗?

Could someone advise me right solution?

更新 在提出建议后,出现以下错误:

Update After suggestion in response I got following error:

...
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

推荐答案

运行setup.py时,它将检查ORACLE_HOME上是否有这些文件夹.

When you run setup.py it will check for any of these folders on your ORACLE_HOME.

possibleIncludeDirs = ["rdbms/demo", "rdbms/public", "network/public",
        "sdk/include"]

如果ORACLE_HOME下没有'include'目录,则即时客户端有时还会在/usr/include/oracle//client中将包含文件(例如oci.h)放置在/usr/include/oracle//client中.

Also the instant client sometimes places the include files, such as oci.h, in /usr/include/oracle//client, if there is no 'include' directory under ORACLE_HOME create a symbolic link to it.

sudo ln -s /usr/include/oracle/11.2/client $ORACLE_HOME/include

好像您缺少客户端SDK

这篇关于cx_Oracle:distutils.errors.DistutilsSetupError:无法找到Oracle包含文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆