Using Pyinstaller to make executable program preparation with Oracle database
First refer to [Linux on PIP installation cx_oracle] To install cx_oracle Library and Oracle driver instantclient_11_2.
This assumes that the Oracle driver or extract to the/opt/instantclient_11_2 directory, the content is as follows:
/opt/instantclient_11_2├── adrci├── BASIC_LITE_README├── genezi├── libclntsh.so.11.1├── libnnz11.so├── libocci.so.11.1├── libociicus.so├── libocijdbc11.so├── ojdbc5.jar├── ojdbc6.jar├── sdk├── uidrvci└── xstreams.jar
Test program
Create a directory MyApp, under which a new test.py file is created with the following contents:
import cx_Oracleconn = cx_Oracle.connect(‘jhinno/[email protected]/jhinno‘) cursor = conn.cursor ()cursor.execute ("select sysdate from dual")row = cursor.fetchone ()print rowcursor.close ()conn.close ()
Packaging spec Files
In the MyApp directory, create the Test.spec file with the following content:
#-*-Mode:python-*-A = Analysis ([' test.py '], pathex=[' MyApp '], hiddenimports=[], hookspath=None, runtime_hooks=None) a.binaries = A.binaries + [(' libclntsh.so ','/opt/instantclient_11_2/libclntsh.so.11.1 ',' BINARY ')]a.binaries = A.binaries + [(' libnnz11.so ','/opt/instantclient_11_2/libnnz11.so ',' BINARY ')]a.binaries = A.binaries + [(' libocci.so ','/opt/instantclient_11_2/libocci.so.11.1 ',' BINARY ')]a.binaries = A.binaries + [(' libociicus.so ','/opt/instantclient_11_2/libociicus.so ',' BINARY ')]pyz = Pyz (a.pure) exe = EXE (PYZ, a.scripts, A.binaries, A.zipfiles, A.datas, Name=' Test ', debug=False, strip=None, upx=True, console=True)
Note the configuration of a.binaries, which adds the libraries that Oracle needs to use.
Packaged
Run the Pyinstaller command as follows:
pyinstaller test.spec
The executable file that generates test in the Myapp/dist directory after packaging can be run directly to test.
Please indicate this address in the form of a link.
This address: http://blog.csdn.net/kongxx/article/details/50637058
Using Pyinstaller to make executable programs that contain Oracle databases