简体   繁体   中英

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. When I built and packaged the application, I had the Oracle 12c client installed. However, when I deployed it to a machine with the 11g client installed, it seems not to work. I get the message "Unable to acquire Oracle environment handle". I assume this is as the result of the application being packaged with Pyinstaller while my ORACLE_HOME was pointed to a 12c client. I know that the cx_Oracle I have was built against both 11g and 12 libraries. So, I'm wondering how I deploy an application using Pyinstaller so it can run with either 11 or 12c client libraries installed?

By the way, I am building this on Linux (debian/Mint 17.2), and deploying to Linux (CentOS 7).

The error "Unable to acquire Oracle environment handle" means there is something wrong with your Oracle configuration. Check to see what libclntsh.so file you are using. The simplest way to do that is by using the ldd command on the cx_Oracle module that PyInstaller has bundled with the executable. Then check to see if there is a conflict due to setting the environment variable ORACLE_HOME to a different client!

If PyInstaller picked up the libclntsh.so file during its packaging you will need to tell it to stop doing that. 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).

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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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