如何在 RHEL 上安装 cx_Oracle for Python?

发布于 2024-11-16 10:53:23 字数 1134 浏览 5 评论 0原文

我正在使用 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

I'm using Active Python since I don't want to be stuck with an old version of Python. I installed the instant client, and added the exports to my bash profile, but I'm getting this cryptic error:

# 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

薔薇婲 2024-11-23 10:53:23

我从这个博客中获取了所有这些 如果您需要更多详细信息,请点击此处

我这样做了并且效果非常好。这是快速总结。
首先去获取适合您的 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"

如果这不起作用,请检查该博客,也许我错过了一些东西。它在全新安装时对我有用。谢天谢地。

抱歉...没有足够的声誉点来提供更多实时链接...因此您必须复制并粘贴或转到博客。

I took all of this from this blog here if you need more details.

I did this and it worked perfectly. Here is the quick summary.
First go get the oracle client stuff for your version of oracle (link is in blog)

Then download to your /tmp/ folder and run the install

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

Now this was the part I struggled with, make sure ALL of your environmental variables are right. Also don't just copy these, go and confirm where your oracle stuff was installed.

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

Now you can go to the ox_Oracle site, make sure to download the version that matches your version of python (if you are not sure run python -V) and your version of the oracle driver.

Download to your TMP folder, install and test with

python -c "import cx_Oracle"

If that doesn't work check that blog, maybe I missed something. It worked for me on a fresh install. Thank goodness.

Sorry... not enough reputation points to give more live links... so you have to copy and paste or go to the blog.

凉城凉梦凉人心 2024-11-23 10:53:23

确保您的路径中存在客户端 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.h 在 Python 3.4 中默认可用。所以我还建议安装 python-devel 包

yum install python-devel

这应该可以解决问题。

Make sure that you've a client sdk present in your path. Oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm which I tried did not come with the sdk. So I had to download zip version for it.

Add this to .bash_rc

export DYLD_LIBRARY_PATH=$ORACLE_HOME

In addition to this, Python 2.7 does not come with Python.h which is available by default in Python 3.4. So I would also suggest to install python-devel package

yum install python-devel

That should resolve the issue.

你爱我像她 2024-11-23 10:53:23

首先,活动状态发行版是另一个发行版,它始终遵循 python.org 的版本。因此,您也可以从 python.org 获取最新版本。我认为,你的意思是系统安装了 python,它可能有点旧。

其次,在 Redhat 安装中检查是否安装了开发工具和标头,例如 gcc、glibc 等以及此处< /a> 是 cx_Oracle 页面上给出的一些构建指令。确保您已关注他们。

First off, active state distribution is another distribution, it always follows the release from python.org. So you get the latest release from python.org too. I think, you meant the system installed python which can be bit older.

Secondly, in your Redhat installation check if you have installed development tools and headers like gcc, glibc etc and here are some build instructions which are given at cx_Oracle page. make sure you have followed them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文