PyInstaller 2.0 bundle file as –onefile 读取文件错误(找不到文件)

from:http://stackoverflow.com/questions/13946650/pyinstaller-2-0-bundle-file-as-onefile

OMG! This PyInstaller really confused me for a bit. If my previous post sounds a little “ranty”, sorry about that.. Anyways, for anyone trying to include a file in a –onefile PyInstaller package this worked for me:

Include this in your .py script:

credit to someone online whose name I don’t remember.. (sorry it’s late and I’m exhausted!)

Then, if you’re using PyInstaller2.0, in cmd, from the pyinstaller-2.0 dir, you can run

That will create a myscriptsname.spec file in the pyinstaller-2.0 dir. It will also create an exe, but that won’t work. It will be updated later. Now edit that .spec, and add the following a.datas line (remember datas, not data). I included a little extra in the .spec file just for reference.

Now, back in cmd, run

This will update your .exe in the /dist dir.

Maybe there’s a better way, or a prettier way, but this worked for me!

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注