First of all, this packaging method can only be used on this computer to operate normal
Preparation:. py File: Your program
GIF file: The picture you want to use
The first step:
Open cmd in the directory where the file is located
输入 pyi-makespec FP.py Will generate a Fp.spec He's a guide to the Pyinstaller package.
FP is my own name, you have to follow your. py file name.
Step Two:
The above variable is actually the path of your image.
Use Picture:
Photo = Tk. Photoimage (file= './socket_one.gif ') This is the way I use pictures when I normally write code without packaging
When I'm going to use this method,
Photo = Tk. Photoimage (File=p_pic) that's the picture.
Step three: Start changing the spec file
Open the file to add code in the red box, save
datas+=[(' _pic.png ', ' d:\\xiutudog\\_pic.png ', ' DATA ')],
datas+=(' _pic.png ', ' d:\\xiutudog\\_pic.png ', ' DATA ')
The above two formats can be tested separately, there is a not error should be.
The red box is the three picture I need, the format is (' Name 1 ', ' 1 ' full path ', ' type '), (' Name 2 ', ' 2 ' full path ', ' type ')
Next, as I described in my previous article, it's okay to pack.
This method is the program specific to the image file path, so no matter where you put the program, you can find the picture where, and normal use.
But no other computer can be found, that is, cannot run
Pyinstaller Packager with pictures