我正在使用Active Python,因为我不想被旧版本的Python所困扰。 我安装了即时客户端,并将导出添加到我的bash配置文件中,但我收到了这个神秘的错误:
# 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
如果您需要更多详细信息,我会从此博客中获取所有这些内容。
我这样做了,效果很好。这是快速摘要。
首先去为你的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"
如果这不起作用检查该博客,也许我错过了一些东西。它在全新安装时对我有用。谢天谢地。
抱歉......没有足够的声望点可以提供更多实时链接...所以你必须复制并粘贴或转到博客。
确保您的路径中存在客户端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
那应该解决这个问题。
首先,活动状态分发是另一个分发,它始终遵循python.org的发布。所以你也从python.org获得最新版本。我想,你的意思是系统安装了python,它可能比较旧。
其次,在你的Redhat安装中检查你是否安装了开发工具和头文件,如gcc,glibc等,这里有一些构建说明,在cx_Oracle页面给出。确保你已经跟着他们。
我从来没有说过我在谈论哪个py,我只是想让我不想使用RHEL附带的python 2.4。 我完全按照指示行事。 这些说明不起作用,GCC失败了。