Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Packaging With PyInstaller

Here are resources and additional documentation about PyInstaller:

00:00 Packaging Your PySimpleGUI Application for Windows. There are many different Python packages that you can use to convert your Python code into an executable for Windows.

00:12 One of the most popular is PyInstaller. As ever, you can install PyInstaller using pip.

00:32 Here, you’ll use PyInstaller to convert the image viewer application that you created earlier into an executable. You can see the command onscreen, and when you run this, you’ll see a lot of output similar to the following.

00:47 When it’s done, you’ll have a subfolder named dist/ in the same folder that contains img_viewer.py. You can go into the dist/ folder to find img_viewer.exe and try running it.

01:11 There will be a lot of other files in the dist/ folder that the executable uses. If you prefer to have only a single executable file, then you can rerun the command using the --onefile flag as seen here onscreen.

01:24 This will still generate the dist/ folder, but this time there should be just a single executable in it. Note that Windows Defender may flag your executable as having a virus if you use the --onefile flag. If it does, then you’ll need to add an exclusion to Windows Security to get it to run.

01:44 This is because Windows executables need to be signed in Windows 10. When you run the executable, you’ll see a console window appear in addition to your user interface. To remove the console, you can use the --noconsole or the --windowed flag when running PyInstaller.

02:15 To learn more about how to use PyInstaller, check out Using PyInstaller to Easily Distribute Python Applications.

Avatar image for Mallesham Yamulla

Mallesham Yamulla on March 31, 2022


I have developed a GUI using pysimpleGUI package. it has few .ico files to show up icons in the window and pop up messages.

I’m creating an executable file of it with below command:

pyinstaller.exe -F –windowed –noconsole sample_pro.py sample_pro.spec –add-data c:/XYX/ABC/venv/lib/site-packages/PyInstaller/bootloader/images/arete_jpeg.ico;images

When I open this same application in some other system it shows up python default icon.

How to create an exe file which show an icon irrespective of file existence in the system ?

Become a Member to join the conversation.