简体   繁体   English

如何使用pyinstaller构建cx_oracle应用程序以使用多个Oracle客户端版本?

[英]How do I build a cx_oracle app using pyinstaller to use multiple Oracle client versions?

I am building an application in Python using cx_Oracle (v5) and Pyinstaller to package up and distribute the application. 我正在使用cx_Oracle(v5)和Pyinstaller在Python中构建应用程序,以打包和分发该应用程序。 When I built and packaged the application, I had the Oracle 12c client installed. 在构建和打包应用程序时,我安装了Oracle 12c客户端。 However, when I deployed it to a machine with the 11g client installed, it seems not to work. 但是,当我将其部署到安装了11g客户端的计算机上时,似乎无法正常工作。 I get the message "Unable to acquire Oracle environment handle". 我收到消息“无法获取Oracle环境句柄”。 I assume this is as the result of the application being packaged with Pyinstaller while my ORACLE_HOME was pointed to a 12c client. 我认为这是由于将我的ORACLE_HOME指向12c客户端时,应用程序与Pyinstaller打包在一起的结果。 I know that the cx_Oracle I have was built against both 11g and 12 libraries. 我知道我已经针对11g和12库构建了cx_Oracle。 So, I'm wondering how I deploy an application using Pyinstaller so it can run with either 11 or 12c client libraries installed? 因此,我想知道如何使用Pyinstaller部署应用程序,使其可以在安装11或12c客户端库的情况下运行?

By the way, I am building this on Linux (debian/Mint 17.2), and deploying to Linux (CentOS 7). 顺便说一句,我正在Linux(debian / Mint 17.2)上构建它,并部署到Linux(CentOS 7)。

The error "Unable to acquire Oracle environment handle" means there is something wrong with your Oracle configuration. 错误“无法获取Oracle环境句柄”表示您的Oracle配置有问题。 Check to see what libclntsh.so file you are using. 检查以查看您正在使用的libclntsh.so文件。 The simplest way to do that is by using the ldd command on the cx_Oracle module that PyInstaller has bundled with the executable. 最简单的方法是在PyInstaller与可执行文件捆绑在一起的cx_Oracle模块上使用ldd命令。 Then check to see if there is a conflict due to setting the environment variable ORACLE_HOME to a different client! 然后检查是否由于将环境变量ORACLE_HOME设置为其他客户端而导致冲突!

If PyInstaller picked up the libclntsh.so file during its packaging you will need to tell it to stop doing that. 如果PyInstaller在打包过程中拾取了libclntsh.so文件,则需要告诉它停止这样做。 There must be an Oracle client (either full client or the much simpler instant client) on the target machine, not just the one file (libclntsh.so). 目标计算机上必须有一个Oracle客户端(完整客户端或简单得多的即时客户端),而不仅仅是一个文件(libclntsh.so)。

You can also verify that your configuration is ok by using the cx_Oracle.so module on the target machine to establish a connection -- independently of your application. 您还可以通过使用目标计算机上的cx_Oracle.so模块来建立连接(与应用程序无关)来验证配置是否正确。 If that doesn't work or you don't have a Python installation there for some reason, you can also use SQL*Plus to verify that your configuration is ok as well. 如果那行不通或者由于某种原因您在那里没有安装Python,您还可以使用SQL * Plus来验证您的配置是否正确。

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

相关问题 如何将 cx_oracle 与 Pyinstaller 捆绑在一起 - How to bundle cx_oracle with Pyinstaller 如何在不安装Oracle客户端和cx_Oracle的情况下访问Oracle数据库? - How do I access an Oracle db without installing Oracle's client and cx_Oracle? 如何使用Google App Engine Flex上的Python cx_Oracle包连接到外部Oracle数据库? - How do I connect to an external Oracle database using the Python cx_Oracle package on Google App Engine Flex? cx_Oracle:使用 Wallet 时如何连接到 Oracle? - cx_Oracle: How do I connect to Oracle when you use a Wallet? 如何使用cx_Oracle在Python 3.4中调用Oracle API函数? - How do I call an Oracle API function in Python 3.4 using cx_Oracle? 在 cx_oracle 上使用多个主机 - Using multiple hosts on cx_oracle 我正在使用 pip 安装 cx_Oracle 安装 cx_Oracle 并收到错误“无法制造轮子” - I am installing cx_Oracle using pip install cx_Oracle and getting an error “Could not build wheels” 如何手动安装cx_Oracle rpm? - How do I manually install cx_Oracle rpm? cx_Oracle:如何迭代结果集? - cx_Oracle: How do I iterate over a result set? 使用python cx_Oracle,如何调用有多个声明的DBMS_METADATA.SET_TRANSFORM_PARAM? - Using python cx_Oracle, how do I call DBMS_METADATA.SET_TRANSFORM_PARAM, which has multiple declarations?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM