You can use PyInstaller to package Python programs as standalone executables. It works on Windows, Linux, and Mac.

PyInstaller Quickstart

Install PyInstaller from PyPI:

pip install pyinstaller

Go to your program’s directory and run:

pyinstaller yourprogram.py

This will generate the bundle in a subdirectory called dist.

pyinstaller -F yourprogram.py

Adding -F (or --onefile) parameter will pack everything into single "exe".

pyinstaller -F --paths=<your_path>\Lib\site-packages  yourprogram.py

running into "ImportError" you might consider side-packages.

 pip install pynput==1.6.8

still runing in Import-Erorr - try to downgrade pyinstaller - see Getting error when using pynput with pyinstaller

For a more detailed walkthrough, see the manual.

Answer from Rumple Stiltskin on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › how do i package my python code into an executable i can send to my friend who does not have python?
r/learnpython on Reddit: How do I package my python code into an executable I can send to my friend who does not have python?
January 4, 2023 -

Hiya thanks for reading! I followed a tutorial and built a tiny game with pygame. I am trying to wrap it up in a single executable file I can send to a friend, such that they won't have to install anything to run it. I have unsuccessfully used p2exe and pyinstaller. Is there a standard way to package python applications? I can share my code or the tutorials/links I am looking at if that is desirable. In gratitude, Prathmun

🌐
PyPI
pypi.org › project › auto-py-to-exe
auto-py-to-exe · PyPI
A .py to .exe converter using a simple graphical interface and PyInstaller in Python.
Discussions

How to compile the Python code to executable binary file like Linux C and Golang
Hi, how can I compile the python files to an executable binary file like Linux C and Golang in different platforms such as Linux, Mac and Windows? More on discuss.python.org
🌐 discuss.python.org
1
1
July 25, 2023
How do I package my python code into an executable I can send to my friend who does not have python?
Pyinstaller is the way to go for me, and afaik for most, why was it unsuccessful? More on reddit.com
🌐 r/learnpython
76
156
January 4, 2023
How can I turn a python project into a single .exe file?
My solution to this same issue was to just install the project as a Python wheel and skip the exe. Then launch from a vbscript which gives you the icon. My project has an add shortcut command that adds a desktop shortcut to the vbscript, which just launches my tkinter app. More on reddit.com
🌐 r/learnpython
44
70
December 12, 2024
Is it a good idea to compile python to exe and then distribute to users?
Large files; at a bare minimum you're zipping up the interpreter, a significant subset of the standard lib, the packer's runtime shim, and your file(s) into the "exe". Performance hit; the way these things work is to make a zip file with the header of an exe that uses a runtime shim to unzip the contents (and optionally decrypt them) into a temp area, run those, then clean up. While there may be some caching that speeds up consecutive runs, there's always a cost in startup and teardown. Difficult to debug; though judicious use of logging can help here, tracebacks may reference lines inside .pyc files that are in an obscure temp directory ... or were, at times, before teardown. Your mileage may vary on this one depending on the bundling/freezing tool you use, but I've certainly had this problem in the recent past. Brittle; on anything more complex (hidden imports, custom C extensions, resource files needed by code, etc), the packaging process can be a multi-step pain and the workarounds and hacks tend to accumulate. Maintaining and revisiting this over and over as your program evolves can be a chore. Obfuscated-at-best; assume any secrets you have in the frozen "exe" are just as public as they would be in the .py source, because they are. Yes, even with PyInstaller's source code crypto option enabled. Licensing issues; none of these installers know anything about your dependencies or whether or not you've included the proper licensing files, etc... a bundled "exe" is a binary distribution for the purposes of licensing and you're copying others source code into that distribution to even work... consulting with lawyers might not be a bad idea here. More on reddit.com
🌐 r/learnpython
10
24
July 24, 2018
🌐
DataCamp
datacamp.com › tutorial › two-simple-methods-to-convert-a-python-file-to-an-exe-file
Three Methods to Convert A Python Script To An .Exe File | DataCamp
January 15, 2026 - To compile our script into an executable, run: python -m nuitka --onefile --follow-imports --include-package=pandas validation.py
🌐
GeeksforGeeks
geeksforgeeks.org › python › convert-python-script-to-exe-file
Convert Python Script to .exe File - GeeksforGeeks
July 12, 2025 - PyInstaller is a powerful tool that makes this process straightforward, allowing you to create executables that are easy for end-users to run. By following the steps outlined in this article, you can convert your Python scripts to .exe files efficiently.
🌐
Python.org
discuss.python.org › python help
How to compile the Python code to executable binary file like Linux C and Golang - Python Help - Discussions on Python.org
July 25, 2023 - Hi, how can I compile the python files to an executable binary file like Linux C and Golang in different platforms such as Linux, Mac and Windows?
🌐
Analytics Vidhya
analyticsvidhya.com › home › 3 ways to convert python scripts to .exe files
3 Ways to Convert Python Scripts to .Exe Files
May 1, 2025 - Convert Python scripts to .exe files effortlessly with PyInstaller, Auto PY to EXE, & cx_Freeze. Free your code from dependencies and explore.
Find elsewhere
🌐
Data to Fish
datatofish.com › executable-pyinstaller
How to Create an Executable of a Python Script using PyInstaller
In this very short tutorial, you will convert a Python script into an executable file using PyInstaller. ... import os with open(os.path.expanduser("~/Desktop") + "/helloworld.txt", "w") as file: file.write("Hello World!") Let's say that this script is saved on your desktop in a folder called Test. Navigate your terminal to this folder:
🌐
GitHub
github.com › oop7 › Py-to-EXE-Guide
GitHub - oop7/Py-to-EXE-Guide: This project guides you through converting Python scripts into standalone .exe files using PyInstaller and auto-py-to-exe. It covers setting up a virtual environment, installing dependencies, and optimizing the final executable. · GitHub
# Compile to executable python -m nuitka --onefile your_script.py # Standalone with all dependencies python -m nuitka --standalone your_script.py # GUI application (no console) python -m nuitka --onefile --windows-disable-console your_script.py # With icon python -m nuitka --onefile --windows-icon-from-ico=app.ico your_script.py
🌐
Codingdeeply
codingdeeply.com › home › can you compile python into exe? discover the process here.
Can You Compile Python into EXE? Discover the Process Here
February 23, 2024 - We will provide a step-by-step ... on sales, nothing changes for you. Compiling Python code into an executable file (EXE) involves using a Python to EXE compiler or converter....
🌐
YouTube
youtube.com › watch
How to Convert a Python file to .EXE - YouTube
Convert python file to .exe . By converting your python file to an executable file, you can share your project with other people, without having them install...
Published: February 24, 2026
🌐
Nuitka
nuitka.net › posts › python-compile-windows.html
Compile Python on Windows — Nuitka the Python Compiler
In case of a terminal program, add one of many options that Nuitka has to adapt for platform specifics, e.g. program icon, and so on. python -m nuitka --onefile --windows-disable-console fancy-program.py · This will create fancy-program.exe.
🌐
Tryexceptpass
tryexceptpass.org › article › package-python-as-executable
tryexceptpass - 4 Attempts at Packaging Python as an Executable
July 28, 2019 - Cython isn’t really built to package code the way I need it. It’s main purpose, as mentioned earlier, is integration between C and Python. Enter our next method: nuitka! Nuitka has been around for quite a while, almost as long as Cython itself. This system exists primarily for making Python modules into executables - which is exactly our goal. It also compiles your code, like Cython, but using its own algorithms.
🌐
YouTube
youtube.com › watch
How to Compile Python Files Into EXE! - YouTube
In this video, we dive into how to use PyInstaller to create an executable from a Python script, complete with a custom icon. We'll start from scratch, setti...
Published: March 28, 2024
🌐
Medium
medium.com › @rohitsaroj29 › how-to-turn-your-python-script-into-an-executable-file-d64edb13c2d4
How to Turn Your Python Script into an Executable File | by Rohit | Level Up Coding
March 16, 2026 - You will need Python 3.6 or higher installed on your computer to follow along. ... PyInstaller is a Python library that can analyze your code and bundle it with the required modules and libraries into a single executable file.
🌐
GeekyHumans
geekyhumans.com › home › compile python scripts to executable files
Compile Python Scripts to Executable Files - Geeky Humans
January 27, 2022 - As you can see it opens a graphical interface that is already self-explanatory you just have to select the app.py file and select what you want in the given option and press on convert.py to .exe and that’s it.
🌐
Vercel
v0-pytoexe.vercel.app
PY to EXE Online Generator | Convert Python to Executable
The generated executable files work on Windows without requiring any additional dependencies. Simply upload your Python file, wait for the conversion process to complete, and download your executable file.
🌐
Medium
medium.com › @moraneus › crafting-a-standalone-executable-with-pyinstaller-f9a99ea24432
Crafting a Standalone Executable with PyInstaller | by Moraneus | Medium
May 17, 2024 - However, not everyone has Python installed, and figuring out how to run your script can be challenging for them. That’s where PyInstaller comes in handy. It’s a tool that takes your script, bundles all its dependencies, and creates a single executable file.
🌐
Tom's Hardware
tomshardware.com › software › programming
How to Create Executable Applications in Python | Tom's Hardware
May 22, 2022 - In this how to, we are going to create a GUI Python application using EasyGUI, and then use auto-py-to-exe to create a standalone application that will run on any Microsoft Windows system, including systems without Python installed. Linux and Mac users will need to use the underlying PyInstaller command line tool.