Now i'm working with Pyinstaller. I have an script which get images from a img folder..
/python |----/img |----|----icon1.ico |----|----icon2.ico |----maint.py
My script to generate .exe is
pyinstaller.py --windowed --noconsole --clean --onefile maint.py
the problem is that only generate the .exe file but the whole folder /img is omitted.
Question: which aditional syntax do I need to put in the previous line in order to get automatically the .exe file + /img folder?
Update 12/18/2013
I mean: that after execution of pyinstaller.py script, with all arguments, I must see in the /dist folder: the .exe file + the /img folder with all icons or bitmaps files I have for my application
Thanks
At least for pyinstaller 4.2 the datas field need to be added as a tuple. If you want to add multiple folders it needs to be something like: ... datas = [('test/dir', 'test/dir'),('test2/dir', 'test2/dir')] ...
When we specify the onefile option, to the PyInstaller, it unpacks all the files to a TEMP directory, executes the file, and later discard the TEMP folder. When you specify the add-data option along with onefile, then you need to read the data referred to in the TEMP folder.
pip will install PyInstaller's dependencies along with a new command: pyinstaller . PyInstaller can be imported in your Python code and used as a library, but you'll likely only use it as a CLI tool. You'll use the library interface if you create your own hook files.
Update 12/19/2013
Finally, we got it!
0. I'm working with current version of PYInstaller + Python 2.67 with Sublime Text as Editor.
1. In case your Py script requires some files, icons, images, you must include a function which retrieves these files from the project folder (in development) or form the temporary data folder (in case of deployment). This script MUST be in your code exactly in the part which you put the relatives paths in order to get the resources. Please follow exactly this guideline: https://stackoverflow.com/a/13790741
2. After the previous code, you must execute for the first time the pyinstaller command -as I post in my question post-.
3. Now, open your .spec file generated after execution of the PYInstaller (located in PYinstaller/) command and add, after "a.binaries" line, the next line into the EXE() function:
exe = EXE(pyz, a.scripts, a.binaries, Tree('..\\python\\images', prefix='images\\'), ....
Keep in mind that in Tree(...) function the first argument is the folder to put outside: which means that I want to include all the content of this folder (notice that I'm putting a relative path respect to the AppStart.py file) into the file's container of my .EXE file.
4. After that modification re-execute the pyinstaller command, but in this case pointing to my .SPEC file:
pyinstaller.py --windowed --noconsole --clean --onefile AppStart\AppStart.spec
And finally my App can be executed as executable without need to copy and paste all external folders as someone mentioned. But as always I consider the good-practical way.
Thanks for your support.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With