oracle / python-oracledb

Python driver for Oracle Database conforming to the Python DB API 2.0 specification. This is the renamed, new major release of cx_Oracle
https://oracle.github.io/python-oracledb
Other
328 stars 66 forks source link

oracledb with cryptography >=43 cause error `DPY-3016: python-oracledb thin mode cannot be used because the cryptography package is not installed` #401

Open zdenop opened 2 hours ago

zdenop commented 2 hours ago

Used versions

cryptography==43.0.1
pyinstaller==6.10.0
oracledb==2.4.1

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:

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

  1. Downgrade cryptography to 42.0.8. IMO this will cause dependency problems soon.
  2. 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
cjbj commented 2 hours ago

Are you saying it works with 42.0.8 but not 43.0.1?

PS I'm not a Windows user.

zdenop commented 2 hours ago

Are you saying it works with 42.0.8 but not 43.0.1?

Yes. Also it does not work with 43.0.0.