我需要在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。未包装的焦油,
转到解压缩文件夹并运行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
在.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
如何解决这样的错误,也许我需要另一个版本的cx_Oracle tar?
下载/解压缩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
有人可以告诉我正确的解决方案吗?
更新 在回答建议后我得到以下错误:
...
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
答案 0 :(得分:13)
运行setup.py时,它将检查ORACLE_HOME上的任何这些文件夹。
possibleIncludeDirs = ["rdbms/demo", "rdbms/public", "network/public",
"sdk/include"]
如果没有&#39; include&#39;,即时客户端有时会将包含文件(如oci.h)放在/ usr / include / oracle //客户端中。 ORACLE_HOME下的目录创建一个符号链接。
sudo ln -s /usr/include/oracle/11.2/client $ORACLE_HOME/include
您似乎错过了Client SDK
答案 1 :(得分:1)
确保为您的操作系统安装即时客户端sdk。
http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html
答案 2 :(得分:1)
安装oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
python -m pip install cx_Oracle
使用pip install
/u01/app/oracle/product/11.2.0/client_1/lib
添加ldconfig
vi /etc/ld.so.conf.d/oracle.conf
/u01/app/oracle/product/11.2.0/client_1/lib
将此位置添加到其中:
ldconfig
import cx_oracle
git filter-branch
答案 3 :(得分:0)
确保您的路径中存在客户端sdk。
此外,我必须将此添加到我的.bash_rc
export DYLD_LIBRARY_PATH=$ORACLE_HOME
除此之外,Python 2.7没有Python.h,它在Python 3.4中默认可用。所以我也建议安装python-devel包
yum install python-devel
这应解决问题。