2011-06-22 45 views
0

我使用的是活动Python,因为我不想被旧版本的Python卡住。我安装了即时客户端,增加了出口到我的bash的个人资料,但我发现了这个神秘的错误:如何在RHEL上安装Python的cx_Oracle?

 
# apy setup.py install --no-compile --root=/tmp/tmpz0JuWASA/cx_Oracle-5.1/_pypminstroot 
running install 
running build 
running build_ext 
building 'cx_Oracle' extension 
gcc -pthread -fno-strict-aliasing -fPIC -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/lib/oracle/11.2/sdk/include -I/opt/ActivePython-2.7/include/python2.7 -c cx_Oracle.c -o build/temp.linux-x86_64-2.7-11g/cx_Oracle.o -DBUILD_VERSION=5.0.4 
In file included from /opt/ActivePython-2.7/include/python2.7/Python.h:58, 
       from cx_Oracle.c:6: 
/opt/ActivePython-2.7/include/python2.7/pyport.h:849:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)." 
In file included from /usr/lib/oracle/11.2/sdk/include/oci.h:3029, 
       from cx_Oracle.c:10: 
/usr/lib/oracle/11.2/sdk/include/ociap.h:10788: warning: function declaration isn’t a prototype 
/usr/lib/oracle/11.2/sdk/include/ociap.h:10794: warning: function declaration isn’t a prototype 
error: command 'gcc' failed with exit status 1 

回答

-2

首先,积极的状态分布是另一种分布,它总是遵循从python.org释放。所以你也可以从python.org获得最新版本。我想,你的意思是系统安装的python可能会稍微老一点。

其次,在你的Redhat安装中,检查你是否已经安装了开发工具和头文件,如gcc,glibc等,here是一些在cx_Oracle页面给出的构建指令。确保你已经跟着他们。

+0

我从来没有说过我在说什么py,我只是想说我不想用RHEL自带的python 2.4。我完全按照方向。这些说明不起作用,GCC失败。 – blackrobot

2

如果您需要更多详细信息,我从这个博客here采取了所有这一切。

我做到了这一点,它的工作完美。这是简要的总结。 首先去获得Oracle客户端工具和您的Oracle版本(链接在博客)

然后下载到你的/ tmp /文件夹,然后运行安装

rpm -ivh oracle-instantclient-basic-10.2.0.4-1.x86_64.rpm 

现在,这是我努力的一部分,确保你所有的环境变量都是正确的。也不要只是复制这些,去确认你的oracle的东西安装。

echo export LD_LIBRARY_PATH=/usr/lib/oracle/10.2.0.4/client64/lib/ >> ~/.bashrc 
echo export ORACLE_HOME=/usr/lib/oracle/10.2.0.4/client64 >> ~/.bashrc 
echo export PATH=$ORACLE_HOME/bin:$PATH >> ~/.bashrc 

现在你可以去ox_Oracle网站,请务必下载符合你的Python版本的版本(如果你不能确定执行python -V)和你的Oracle驱动程序的版本。

下载到您的TMP文件夹,安装和测试与

python -c "import cx_Oracle" 

如果不工作检查的博客,也许我错过了什么。它在我的全新安装上工作。谢天谢地。

对不起...没有足够的信誉点给予更多的实时链接...所以你必须复制粘贴或转到博客。

0

确保您的客户端sdk存在于您的路径中。我试过的Oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm没有附带sdk。所以我不得不下载zip版本。

添加这.bash_rc

export DYLD_LIBRARY_PATH=$ORACLE_HOME 

除此之外,Python 2.7版不来与Python.h这是默认提供的Python 3.4。所以我也建议安装python-devel软件包

yum install python-devel 

这应该可以解决这个问题。