I have a problem with pyinstaller when adding some data files, such as images and txts, to a python program. For example, I created a toolbar with icons, and I store them in a separate folder with images. I also have some txt and xml files for storing some configurations. These txt ant xml files are stored in another folder named data_files. All py files are stored in another folder named source.
When I try to create this python program using pyinstaller, pyinstaller can successfully create the entire source folder, but image folders and data_files cannot be created. I checked the pyinstaller documentation, but I could not find a solution. I did a lot of Google searches and found only this resource as useful, but it is a very inadequate resource.
My main question is: how can I create an exe file with a separately created folder, such as images and confs, using pyinstaller?
Edit: I found a solution. When you create the specification file, you must have the a.datas parameter.
# -*- mode: python -*- a = Analysis([os.path.join(HOMEPATH,'support/_mountzlib.py'), os.path.join(HOMEPATH,'support/useUnicode.py'), '/home/vmode/Desktop/derlem2/sources/TextSTAT.py'], pathex=['/home/pyinstaller']) a.datas += [("Images/New.gif","/home/vmode/Desktop/derlem2/Images/New.gif","DATA")] a.datas += [("Images/Open.gif","/home/vmode/Desktop/derlem2/Images/Open.gif","DATA")] a.datas += [("Images/Column.gif","/home/vmode/Desktop/derlem2/Images/Column.gif","DATA")] pyz = PYZ(a.pure) exe = EXE( pyz, a.scripts, a.binaries, a.zipfiles, a.datas, name=os.path.join('dist', 'TextSTAT'), debug=False, strip=False, upx=True, console=1 )
The above specification code is for my project. As you can see from this specification code, I have included 3 icons to create using the python program. When the program is generated, there is a separate executable file with built-in icons.
But what if we have so many files? Suppose we have 1000 icons to use in our program. It is very inadequate to write to the specification file manually. To read the file directory there must be a loop system and dynamically add these files. But I could not find how to add these files dynamically. I think there is no chance to add these so many files. If anyone knows, please share.