简体   繁体   English

为什么pyinstaller生成的cx_oracle应用程序可以在新的CentOS计算机上运行,​​而不能在安装了Oracle客户端的计算机上运行?

[英]Why does pyinstaller generated cx_oracle application work on fresh CentOS machine but not on one with Oracle client installed?

I wrote a python application that uses cx_Oracle and then generates a pyinstaller bundle (folder/single executable). 我编写了一个使用cx_Oracle的python应用程序,然后生成pyinstaller捆绑包(文件夹/单个可执行文件)。 I should note it is on 64 bit linux. 我应该注意它在64位linux上。 I have a custom spec file that includes the Oracle client libraries so everything that is needed is in the bundle. 我有一个包含Oracle客户端库的自定义规范文件,因此捆绑包中包含了所有需要的内容。

When I run the bundled executable on a freshly installed CentOS 7.1 VM, (no Oracle software installed), the program connects to the database successfully and runs without error. 当我在新安装的CentOS 7.1 VM(未安装Oracle软件)上运行捆绑的可执行文件时,该程序成功连接到数据库并且运行无误。 However, when I install the bundled executable on another system that contains RHEL 7.2, and I try to run it, I get 但是,当我在包含RHEL 7.2的另一个系统上安装捆绑的可执行文件并尝试运行它时,我得到了

Unable to acquire Oracle environment handle. 无法获取Oracle环境句柄。

My understanding is this is due to an Oracle client installation that has some sort of conflict. 我的理解是,这是由于Oracle客户端安装存在某种冲突。 I tried unsetting ORACLE_HOME on the machine giving me errors. 我尝试在计算机上取消设置ORACLE_HOME的错误。 It's almost as though the program is looking for the Oracle client libraries in a location other than in the location where I bundled the client files. 程序看起来好像是在我捆绑客户端文件的位置之外的其他位置寻找Oracle客户端库。

It seems like it should work on both machines or neither machine. 似乎它应该在两台计算机上都可以工作,也不能在两台计算机上都工作。 I guess I'm not clear on how the Python application/cx_Oracle finds the Oracle client libraries. 我想我不清楚Python应用程序/ cx_Oracle如何找到Oracle客户端库。 Again, it seems to have found them fine on a machine with a fresh operating system installation. 同样,似乎在安装了全新操作系统的计算机上它们也不错。 Any ideas on why this is happening? 为什么会这样?

One thing that you may be running into is the fact that if you used the instant client RPMs when you built cx_Oracle an RPATH would have been burned into the shared library. 您可能会遇到的一件事是,如果在构建cx_Oracle时使用即时客户端RPM,则会将RPATH刻录到共享库中。 You can examine its contents and change it using the chrpath command. 您可以检查其内容并使用chrpath命令对其进行更改。 You can use the special path $ORIGIN in the modified RPATH to specify a path relative to the shared library. 您可以在修改后的RPATH中使用特殊路径$ ORIGIN来指定相对于共享库的路径。

If an RPATH isn't the culprit, then you'll want to examine the output from the ldd command and see where it is looking and then adjust things to make it behave itself! 如果不是RPATH的罪魁祸首,那么您将需要检查ldd命令的输出,查看它的查找位置,然后进行调整以使其自身发挥作用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM