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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With