Bundling data files with PyInstaller (--onefile)

前端 未结 13 1828
清歌不尽
清歌不尽 2020-11-21 13:28

I\'m trying to build a one-file EXE with PyInstaller which is to include an image and an icon. I cannot for the life of me get it to work with --onefile.

<
13条回答
  •  无人及你
    2020-11-21 13:46

    Instead for rewriting all my path code as suggested, I changed the working directory:

    if getattr(sys, 'frozen', False):
        os.chdir(sys._MEIPASS)
    

    Just add those two lines at the beginning of your code, you can leave the rest as is.

提交回复
热议问题