Bundling Data files with PyInstaller 2.1 and MEIPASS error --onefile

后端 未结 1 791
伪装坚强ぢ
伪装坚强ぢ 2020-12-03 01:45

This question has been asked before and I can\'t seem to get my PyInstaller to work correctly. I have invoked the following code in my mainscript.py file:

d         


        
相关标签:
1条回答
  • 2020-12-03 02:47

    I think I see the problem. You're not feeding data_files into your Analysis object. Here's how I add my data files in my .spec file:

    a = Analysis(....)
    a.datas += [('7z.dll', '7z.dll', 'DATA')]
    a.datas += [('7z.exe', '7z.exe', 'DATA')]
    a.datas += [('collection.xml', 'collection.xml', 'DATA')]
    a.datas += [('License.html', 'License.html', 'DATA')]
    
    pyz = PYZ(a.pure)
    
    exe = EXE(pyz,
              a.scripts + [('O', '', 'OPTION')],
              a.binaries,
              a.zipfiles,
              a.datas,
              name=os.path.join('dist', 'blah.exe'),
              debug=False,
              strip=None,
              upx=False,
              console=True,
              icon=r'..\NCM.ico')
    

    Notice I'm not using COLLECT() at all.

    If you checkout the 2.1 documentation at: PyInstaller Spec File Operation you'll notice that COLLECT() isn't used for --onefile mode.

    If you look at the extracted directory pointed at by sys._MEIPASS you'll probably notice that with your spec file that the data file simply isn't there at all.

    I hope this helps.

    0 讨论(0)
提交回复
热议问题