Bundling data files with PyInstaller (--onefile)

前端 未结 13 1573
清歌不尽
清歌不尽 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 14:09

    The most common complaint/question I've seen wrt PyInstaller is "my code can't find a data file which I definitely included in the bundle, where is it?", and it isn't easy to see what/where your code is searching because the extracted code is in a temp location and is removed when it exits. Add this bit of code to see what's included in your onefile and where it is, using @Jonathon Reinhart's resource_path()

    for root, dirs, files in os.walk(resource_path("")):
        print(root)
        for file in files:
            print( "  ",file)
    

提交回复
热议问题