Reputation: 6597
I have a simple python script that imports cx_Oracle and then makes an sql query. It all works fine when run from python. I have Oracle SQL developer installed on my computer, which is free.
When I then compile the program with 'pyinstaller main.py' everything compiles fine and i can also start the problem. But as soon as an SQL query is made from that program, the following runtime error occurs:
cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle
I have tried the following:
None of this has worked.
Any suggestions what else I can do are much appreciated.
Upvotes: 3
Views: 2937
Reputation: 6597
I found the solution:
When running pyinstaller as normal one file will be missing in the compilation. It needs to be manually included:
For that you need to edit the line with as follows:
binaries+[('oraociei12.dll','oraociei12.dll','BINARY')],
make sure that oraociei12.dll is in the current folder.
block_cipher = None
a = Analysis(['LDM-shark.py'],
pathex=['C:\\Users\\dicknic\\AppData\\Local\\Home\\dev\\LDM'],
binaries=None,
datas=None,
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries+[('oraociei12.dll','oraociei12.dll','BINARY')],
a.zipfiles,
a.datas,
name='mainprogram',
debug=False,
strip=False,
upx=True,
console=True )
In a second step run pyinstaller again but with the spec file. pyinstaller mainprogram.spec
and it will work
Upvotes: 6
Reputation: 1733
The solution described above worked for me, with one small modification - I had to include an extra DLL:
a.binaries+[('oraociei12.dll','C:\\instantclient_12_1\\oraociei12.dll','BINARY'), ('oraons.dll','C:\\instantclient_12_1\\oraons.dll','BINARY')]
Note: I am running Python 3.5 64-bit, PyInstaller 3.2.1, Oracle InstantClient 12.1 64-bit, and Windows 7 64-bit. Hope this helps someone.
Upvotes: 1
Reputation: 1759
I used the following rule:
a.binaries+[('oraociei12.dll','C:\\oracle\\product\\instantclient_12_1\\oraociei12.dll','BINARY')],
The second element of the tuple is the complete path of the DLL. It's better to know this...
There is a open issue on github for the Pyinstaller project at https://github.com/pyinstaller/pyinstaller/issues/1924
I hope this could help
Upvotes: 2