Search code examples
pythonpyinstaller

Error python38.dll not found while using Merge method in Pyinstaller


I have two EXE's let's say one.exe and two.exe which were created using Pyinstaller (as --onefile). The one.exe(74 MB in size) calls two.exe(50 MB in size) upon execution. Since these are bundled EXE's they extract all the files to the temporary folder first and then use them. so upon running one.exe, it takes about 40sec to unbundle and start the actual program, and then after the one.exe calls the two.exe, it takes another 40 secs. I am trying to bring down the loading times of the exe's so, I am using the Merge method to combine the spec files of both EXE's and make use of shared resources as mentioned in this Link . I also followed this Link to try out different things to get it working but the two.exe is not able to use shared python.dll I am able to create the exe's successfully but after running the two.exe it gives me this error, how do I make it work.

Any help would be appreciated.

here is the spec file I used:

la_block_cipher = None
la_options = [('W ignore', None, 'OPTION') ]

da_block_cipher = None

la = Analysis(['C:\\Rohith\\python\\ONE.py'],
             pathex=['C:\\Rohith\\python'],
             binaries=[],
             datas=[
            ('C:\\Rohith\\python\\ONE.py','.'),
            ('C:\\Rohith\\python\\pages','pages'),
            ('C:\\Rohith\\python\\static','static'),
],
             hiddenimports=[],
             hookspath=[],
             hooksconfig={},
             runtime_hooks=[],
             excludes=['PySide', 'asyncio', 'curses', 'overlapped', 'PyQt4', 'scipy', 'matplotlib', 'tornado', 'MySQLdb', 'psycopg2', 'win32com','tkinter','PyQt6','PyQt5'],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=la_block_cipher,
             noarchive=False)



da = Analysis(['C:\\Rohith\\python\\TWO.py'],
             pathex=['C:\\Rohith\\python'],
             binaries=[],
             datas=[
            ('C:\\Rohith\\python\\TWO.py','.'),
            ('C:\\Rohith\\python\\pages','pages'),
            ('C:\\Rohith\\python\\static','static'),

],
             hiddenimports=[],
             hookspath=[],
             hooksconfig={},
             runtime_hooks=[],
             excludes=['PySide', 'PyQt4', 'scipy', 'matplotlib', 'tornado', 'MySQLdb', 'psycopg2', 'win32com','tkinter','PyQt6','PyQt5'],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=da_block_cipher,
             noarchive=False)

MERGE((la, 'ONE', 'ONE'),(da, 'TWO', 'TWO'))


la_pyz = PYZ(la.pure, la.zipped_data,
             cipher=la_block_cipher)

da_pyz = PYZ(da.pure, da.zipped_data,
             cipher=da_block_cipher)

la_exe = EXE(la_pyz,
          la.scripts,
          la.binaries,
          la.zipfiles,
          la.datas,
          [],
          name='ONE',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=True,
          disable_windowed_traceback=False,
          target_arch=None,
          codesign_identity=None,
          entitlements_file=None )



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

da_exe = EXE(da_pyz,
          da.scripts,
          da.binaries,
          da.zipfiles,
          da.datas,
          [],
          name='TWO',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=True,
          disable_windowed_traceback=False,
          target_arch=None,
          codesign_identity=None,
          entitlements_file=None )


coll = COLLECT(la_exe,
               la.binaries,
               la.zipfiles,
               la.datas,
               da_exe,
               da.binaries,
               da.zipfiles,
               da.datas,
               strip=False,
               upx=True,
               upx_exclude=[],
               name='Combined_Foo',
)




Solution

    1. Make separate spec files for each.
    2. Then combine them into a single spec file.
    3. Make sure the pathex in the analysis is correct and verify each component's paths inside the datas.
    4. if the exe still loads slow, try to sign the exe. By this, I'm to add a digital signature to the EXE. This will prevent windows from flagging EXE as a threat.