pyinstaller multipackage错误(MERGE方法)

pyinstaller multipackage error (MERGE method)

我遵循了 Pyinstaller 文档 (https://pyinstaller.readthedocs.io/en/stable/spec-files.html#multipackage-bundles) 的多包捆绑包(在规范文件中调用 MERGE 方法)。构建很顺利,正如预期的那样,第二个包没有共享依赖项……事实上它不起作用! :)

加载错误 Python DLL 'path/to/second/pakage/python38.dll' LoadLibrary: 找不到指定的模块

如果我交换 MERGE 调用的参数,第一个包不工作,所以它们不共享依赖项。

这是我对 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')

我遇到了同样的问题。在我的例子中,我能够通过使用对 COLLECT 的单个调用来使其工作,其中包括两个可执行文件。这里建议 https://github.com/pyinstaller/pyinstaller/issues/1358#issuecomment-421430592 。在您的情况下,它看起来像:

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') 

两个可执行文件都在同一个名为 D-QSAR_and_QSAR_pyinstaller 的文件夹中。