os.environ['ORACLE_HOME'] = '/usr/lib/oracle/XX.Y/client64'
try:
    os.execv(sys.argv[0], sys.argv)
except Exception as exc:
    print('Failed re-exec:', exc)
sys.exit(1)
print('Success:', os.environ['LD_LIBRARY_PATH'])
Установка LD_LIBRARY_PATH изнутри Python