0

I am trying to generate a single file executable using a pyinstaller for a python based GUI. The GUI contains images and a lot of python files in different folder. I generated the executable by the below command in command prompt:

pyinstaller --onefile --windowed --onedir --icon=someFigure.ico main_window.py

After excecuting the below command, a dist folder is created. A main_window folder is created inside dist folder. In the main_window folder, I had put all my images and extra python files folder. I included the libraries from site-packages folder. When I click the main_window.exe created inside the main_window folder, which is inside dist folder, the GUI works well. But I need a single file executable( for example as generated by visual studio for C# WPF GUIs). What should I do? This is turning out to be difficult problem for me? Please guide.

  • Get rid of ```--onedir``` and just use ```--onefile``` – jbflow Oct 27 '20 at 15:27
  • I didnot worked. It created a dist folder with main_window.exe inside it. I really donot know the way to include other folders and libraries to include with it. It didnot worked. – Manu Chaudhary Oct 27 '20 at 16:26
  • ```--onefile``` Will create a single file executable with everything packaged inside of it. If the executable created doesn't work you may need to specify the images inside the spec file manually or you can use the ```--add-data``` command. – jbflow Oct 27 '20 at 16:48
  • Please provide more info, showing your spec file and any error that prints to the console when running the .exe that is generated. – jbflow Oct 27 '20 at 16:48
  • I have 3 folders and 1 can library folder. I am not sure how to add folders using the add data command. I tried this : pyinstaller --onefile --windowed --onefile --add-data image status_dict thread_file can --icon=someFigure.ico main_window.py . But this doesnot work. – Manu Chaudhary Oct 27 '20 at 17:15
  • if you have a lot of files your better of providing them to the datas option in the spec file. You can read up on it in the official documentation here: https://pyinstaller.readthedocs.io/en/stable/spec-files.html#using-spec-files These questions might help you: https://stackoverflow.com/questions/11322538/including-a-directory-using-pyinstaller https://stackoverflow.com/questions/20602727/pyinstaller-generate-exe-file-folder-in-onefile-mode/20677118#20677118 – jbflow Oct 27 '20 at 17:33

0 Answers0