Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pyinstaller multipackage error (MERGE method)

I followed the Pyinstaller doc (https://pyinstaller.readthedocs.io/en/stable/spec-files.html#multipackage-bundles) for a multipackage bundle (calling the MERGE method in the spec file). The build went smooth and, as expected, the second package does not have the shared dependencies... In fact it does not work! :)

Error Loading Python DLL 'path/to/second/pakage/python38.dll' LoadLibrary: the specified module could not be found

If I swap the arguments of the MERGE call, is the first package that is not working, so they are not sharing dependencies.

Here my spec on Pyinstaller 4.3:


block_cipher = None


files_D = [('src_D-QSAR/static/*.*', 'static'),
           ('src_D-QSAR/templates/*.*', 'templates'),
          ] 

files_Q = [ ('src_QSARpy/pics/*.*', 'pics') ]  

OB_libs = [('src_QSARpy/OB_libs/*.dll', '.'),
           ('src_QSARpy/OB_libs/*.obf', '.'),
          ]

DQSAR_a = Analysis(['src_D-QSAR/D-QSAR.py'],
             pathex=[], 
             binaries=[],
             datas=files_D,
             hiddenimports=[],
             hookspath=['.'],  # add local hooks
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)


QSARpy_a = Analysis(['src_QSARpy/QSARpy_GUI.py'],
             pathex=[],
             binaries=OB_libs,
             datas=files_Q,
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)

MERGE( (QSARpy_a, 'QSARpy_GUI', 'QSARpy2'), (DQSAR_a, 'D-QSAR', 'D-QSAR'), )


DQSAR_pyz = PYZ(DQSAR_a.pure, 
                 DQSAR_a.zipped_data,
                 cipher=block_cipher)

DQSAR_exe = EXE(DQSAR_pyz,
                 DQSAR_a.scripts,
                 [],
                 exclude_binaries=True,
                 name='D-QSAR',                             # .exe
                 debug=False,
                 bootloader_ignore_signals=False,
                 strip=False,
                 upx=True,
                 console=True,
                 icon='src_D-QSAR/static/D-QSAR.ico', )

DQSAR_coll = COLLECT(DQSAR_exe,
                      DQSAR_a.binaries,
                      DQSAR_a.zipfiles,
                      DQSAR_a.datas,
                      strip=False,
                      upx=True,
                      upx_exclude=[],
                      name='D-QSAR_pyinstaller')            # directory



QSARpy_pyz = PYZ(QSARpy_a.pure,
                 QSARpy_a.zipped_data,
                 cipher=block_cipher)

QSARpy_exe = EXE(QSARpy_pyz,
                 QSARpy_a.scripts,
                 [],
                 exclude_binaries=True,
                 name='QSARpy2',
                 debug=False,
                 bootloader_ignore_signals=False,
                 strip=False,
                 upx=True,
                 console=True,
                 icon='src_QSARpy/pics/QSARpy.ico', )

QSARpy_coll = COLLECT(QSARpy_exe,
                      QSARpy_a.binaries,
                      QSARpy_a.zipfiles,
                      QSARpy_a.datas,
                      strip=False,
                      upx=True,
                      upx_exclude=[],
                      name='QSARpy2_pyinstaller')
like image 987
Thomas Avatar asked Jul 11 '26 13:07

Thomas


1 Answers

I had the same problem. In my case I was able to get it to work by using a single call to COLLECT which includes both executables. This is suggested here https://github.com/pyinstaller/pyinstaller/issues/1358#issuecomment-421430592 . In your case it would look something like:

coll = COLLECT(DQSAR_exe,
               DQSAR_a.binaries,
               DQSAR_a.zipfiles,
               DQSAR_a.datas,
               QSARpy_exe,
               QSARpy_a.binaries,
               QSARpy_a.zipfiles,
               QSARpy_a.datas,
               strip=False,
               upx=True,
               upx_exclude=[],
               name='D-QSAR_and_QSAR_pyinstaller') 

Both executables would be in the same folder called D-QSAR_and_QSAR_pyinstaller.

like image 57
mirko Avatar answered Jul 13 '26 15:07

mirko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!