Make an executable python file

Written by: Brandon Molyneaux

Making an executable file in python is incredibly simple - all you have to do is install the PyInstaller package (if you haven't already), type in a command into the command line, and celebrate!

If you haven't yet, go ahead and install PyInstaller using pip in the command line.

> pip install pyinstaller

From here, navigate to the directory the file is in. For example, if we wanted to make "sample.py" executable, and it was in my "pythonProject" folder, it would be:

> cd C:/Users/Username/Desktop/pythonProject

Type in the following into the following into the command line:

> pyinstaller --onefile sample.py

and let it do it's magic. Do note it is important you have to have the extension (in this case, .py) after the file name. After about 5 seconds or so, you should have a bunch of folders as pictured on the right.

From here, go into the "dist" folder. This is where your executable file is.

Go ahead and drag and drop it to wherever you want. You may delete the other files, since you don't need them anymore.

When you click on the file you just moved, the script will run. Happy scripting!

If you have any questions and/or comments, feel free to shoot me a DM or tweet at me @WxBDM or, send me an email