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

放肆的年华 提交于 2019-11-27 12:55:36

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!