Bundling Data files with PyInstaller 2.1 and MEIPASS error –onefile

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.

Leave a Comment