0

I'm using pyinstaller main2.spec command. The main2.spec file is the next:

# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
    ['main.py'],
    pathex=[],
    binaries=[],
    datas=[
        ('./backend', 'backend'),
        ('./classes', 'classes'),
        ('./common', 'common'),
        ('./functions', 'functions'),
        ('./sql', 'sql'),
        ('./interfaces', 'interfaces')
    ],
    hiddenimports=['cryptography.hazmat.primitives.kdf.pbkdf2', 'uuid'],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
)
pyz = PYZ(a.pure)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.datas,
    [],
    icon='./logo.ico',
    name='CREDTI',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=True,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)

It generates a CREDTI.exe file. When i execute the file and click a button that get data from a oracle database, it give me the next error:

Traceback (most recent call last):
File "main.py", line 164, in send_mail_if
File "backend\login.py", line 16, in login
File "sql\sql.py", line 44, in select_all_fields_with_where
File "sql\sql.py", line 9, in create_connection
File "oracledb\connection.py", line 1194, in connect
File "oracledb\connection.py", line 575, in __init__
File "src\\oracledb\\impl/thin/connection.pyx", line 318, in oracledb.thin_impl.ThinConnImpl.__init__
File "src\\oracledb\\impl/thin/connection.pyx", line 78, in oracledb.thin_impl.BaseThinConnImpl.__init__
File "oracledb\errors.py", line 195, in _raise_err
oracledb.exceptions. NotSupportedError: DPY-3016: python-oracledb thin mode cannot be used because the cryptography package is not installed

I read that the error would be fixed adding "from cryptography.hazmat.primitives.kdf import pbkdf2" and "import encodings.idna" in imports, but it works with Fernet and i'm not using that. I still tried, adding in main.py and sql.py files, but it didn't work.

I'm using the following versions:

cryptography 44.0.1
oracledb     2.5.1
pyinstaller  6.12.0

I have another project with those versions, but I have no errors there.

2
  • 1
    Changing the import of cryptography to a local folder in the datas section of the main2.spec file fixed it. Commented Jul 11 at 21:32
  • Can you post the updated main2.spec file as an answer to make it easier for people to see what was needed? Commented Jul 16 at 4:30

1 Answer 1

0

It was resolved downloading the library cryptography in AppData folder and adding the path in the spec file's data list

# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
    ['main.py'],
    pathex=[],
    binaries=[],
    datas=[
        ('./backend', 'backend'),
        ('./classes', 'classes'),
        ('./common', 'common'),
        ('./functions', 'functions'),
        ('./sql', 'sql'),
        ('./interfaces', 'interfaces'),
        ('C:\\Users\\paul.delacruz\\AppData\\Local\\Programs\\Python\\Python312\\Lib\\site-packages\\cryptography', 'cryptography')
    ],
    hiddenimports=['uuid'],
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
)
pyz = PYZ(a.pure)

exe = EXE(
    pyz,
    a.scripts,
    a.binaries,
    a.datas,
    [],
    icon='./logo.ico',
    name='SISCRETI',
    debug=False,
    bootloader_ignore_signals=False,
    strip=False,
    upx=True,
    upx_exclude=[],
    runtime_tmpdir=None,
    console=False,
    disable_windowed_traceback=False,
    argv_emulation=False,
    target_arch=None,
    codesign_identity=None,
    entitlements_file=None,
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.