Package a Python program to a single Executable file with Pyinstaller

The advantage of packaging a program is that the user do NOT need any programming environment to use the packaged software.

Packaging a program is very common.For example, when you install most of the software, the ‘setup’ installer will install a packaged software into your computer as a folder and add a shortcut of the executable to your desktop.

However, packaging the program into a single file is much more difficult, I’ll explain why later, let us see how to do it for a Python project.

First things first, make sure you have pyinstaller. I’ve used other libraries like py2exe, but pyinstaller is the best in terms of its compatibility, stability, and user-friendly, the list goes on and on.

in the command window

-> pyinstaller  -o image.ico  -F  –upx-dir upxfolder

-c  (default)  open a console window

-w  will NOT open a console window

The biggest problem when packaging, especially to a single file:

can not find some specific library dependencies

these are tons of solutions online, but much are so complex and not direct

these is a very simple solution:

Locate the library you import in your program (the one failed packaging) then move the source code to your current directory with the program you wrote, the CHANGE the name of the source code file and change the library name you import.

The packaging software will then search dependency files from the files you made.

Here’s an example:



30 days of code

Day 6


Given a string,S , of length N  that is indexed from 0 to N-1, print its even-indexed and odd-indexed characters as 2 space-separated strings on a single line (see the Sample below for more detail).

Note: is considered to be an even index.

Sample Input

Sample Output

My code

official answer:

Day 8

Sample Input

Sample Output

my answer


Day 12: Inheritance

Day 14: Scope

The absolute difference between two integers

Day 15: Linked List


A Image Crawler I wrote Added GUI (graphical user interface) & packaged into a single .exe file

in 2014, I’ ve written a Python image crawler for a specific website Cure WorldCosplay,  a website that attracts cosplayers  all over the world post their own pictures . Which has about 10k active members and up to 10 million pictures posted.  

The pros is the program is packaged into a single executable file, no programming environment needed. But some virus detection software could report unsafe file.

 Here the program is!     

Click names below for download

With interface

Without interface

Theoretically, if you have enough disk space, you can download all the pics of that website (about 9800 Gigabyte), the only limit is your bandwidth. I have deployed 36 crawlers on a Linux server at the same time, they download pics 24/7 at the maximum internet bandwidth.


How to use it: