oracledb with cryptography >=43 cause error `DPY-3016: python-oracledb thin mode cannot be used because the cryptography package is not installed` #401
import os
from contextlib import suppress
import oracledb
from dotenv import load_dotenv
with suppress(BaseException):
oracledb.init_oracle_client()
print(f'Oracle client version: {oracledb.clientversion()}')
oracle_cnx = None
load_dotenv()
try:
oracle_cnx = oracledb.connect(
user=os.getenv('user'), password=os.getenv('pwd'), dsn=os.getenv('db')
)
except oracledb.DatabaseError as err:
(error,) = err.args
print(error)
if oracle_cnx:
print('Oracle connection works.')
oracle_cnx.close()
app is created with:
python -OO -m PyInstaller -F -c --noupx --noconfirm --hidden-import secrets --hidden-import asyncio --hidden-import uuid test.py
and run by:
dist\test.exe
which produce:
DPY-3016: python-oracledb thin mode cannot be used because the cryptography package is not installed
Workarounds
Downgrade cryptography to 42.0.8. IMO this will cause dependency problems soon.
set PATH=C:\oracle\ora122\client_x64\bin before running dist\test.exe. This will cause my app will not be usable on other computers and anyway it is not needed by cryptography==42.0.8
Used versions
oracledb.version: 2.4.1 platform.platform: Windows-10-10.0.19045-SP0 sys.maxsize > 2**32: True platform.python_version: 3.11.9
Error reproducing
Example code:
app is created with:
python -OO -m PyInstaller -F -c --noupx --noconfirm --hidden-import secrets --hidden-import asyncio --hidden-import uuid test.py
and run by:
dist\test.exe
which produce:
DPY-3016: python-oracledb thin mode cannot be used because the cryptography package is not installed
Workarounds
cryptography
to 42.0.8. IMO this will cause dependency problems soon.set PATH=C:\oracle\ora122\client_x64\bin
before runningdist\test.exe
. This will cause my app will not be usable on other computers and anyway it is not needed bycryptography==42.0.8