Skip to content

Convert PY to EXE

Package Python source files as Windows executables with PyInstaller and compatible alternatives.

Convert PY files online

We don’t have a dedicated online converter for PY to EXE yet, but you can convert PY files online to these formats:

Want to convert PY to EXE?

Let us know. We pick the conversions to add next by how many people ask for them.

How to convert py to exe file

A Windows user may need to run a Python program without installing Python or its packages. Packaging the program as an EXE creates a distributable Windows application, although it does not make the program portable to other operating systems.

What the PY format is

.py is the source-file extension for Python programs. Developers write PY files in editors and IDEs such as Visual Studio Code, PyCharm, IDLE, or Notepad++, then run them with the Python interpreter or import them as modules.

A PY file contains readable Python source code, not a Windows executable. Running it normally requires a compatible Python version and all dependencies used by the program, such as requests, PyQt6, or pandas. Python developers, data analysts, automation authors, and desktop-application developers commonly use this format.

What the EXE format is

.exe is the usual filename extension for a Windows executable, generally using the Windows Portable Executable format. Windows can launch an EXE directly, so recipients usually do not need a separate Python installation when the interpreter, libraries, and application files have been packaged with it.

EXE packaging suits desktop utilities, graphical applications, internal tools, and installers. An EXE is normally Windows-specific; building one does not create a macOS, Linux, Android, or web application.

How to build an EXE with PyInstaller

  1. Use a Windows development machine with the Python version and architecture required by the application. Create and activate a virtual environment if possible, then install the application dependencies and PyInstaller:

python -m pip install -r requirements.txt
python -m pip install pyinstaller

  1. Open a terminal in the project directory containing the entry script:

cd C:\path\to\project

  1. Build a console application as one file:

pyinstaller --onefile app.py

The executable is normally created as dist\app.exe. Without --onefile, PyInstaller creates a directory distribution containing the EXE and its dependencies. The directory form usually starts faster and is easier to diagnose; the one-file form is simpler to copy but extracts bundled components to a temporary directory when it starts.

  1. For a graphical application that should not open a console window, set a name and optional icon:

pyinstaller --onefile --windowed --name MyProgram --icon app.ico app.py

Use the console build while diagnosing errors. --windowed hides the console, so messages printed by the program are no longer visible in a terminal.

  1. Test dist\MyProgram.exe on a clean Windows computer or virtual machine. A development computer may conceal missing files because it already has Python packages, environment variables, or project directories installed.

Include files and dynamic imports

PyInstaller detects many ordinary imports, but dynamically loaded modules, templates, images, configuration files, plugins, and other assets may require explicit options. On Windows, add an asset directory with:

pyinstaller --onefile --add-data "assets;assets" app.py

The semicolon separates the source path from the destination path on Windows; use a colon when building on macOS or Linux. Add a module that automatic analysis missed with --hidden-import package_name. For repeatable builds, inspect the generated app.spec file, edit its data and hidden-import settings, and build it with pyinstaller app.spec.

Graphical and alternative tools

auto-py-to-exe is a graphical front end for PyInstaller. Install and start it with:

python -m pip install auto-py-to-exe
auto-py-to-exe

Select the script, choose Onefile or One Directory, select Console Based or Window Based, add data files and an icon, then use Convert .py to .exe. The interface generates a PyInstaller command that can be retained in a build script.

cx_Freeze is another local packaging option. Install it with python -m pip install cx-Freeze and configure the entry script, included packages, files, and base type in its documented build configuration. It generally produces a directory distribution rather than the same one-file workflow commonly used with PyInstaller.

Browser-based converters are unsuitable for most PY files: they require uploading source code, cannot reliably reproduce a project's virtual environment or native dependencies, and may expose credentials or proprietary logic. Use local PyInstaller, auto-py-to-exe, or cx_Freeze for private or dependency-heavy projects rather than an unverified online service.

Compatibility and security limitations

Packaging is not a source-code conversion or compilation into universally portable native code. PyInstaller bundles Python bytecode, the interpreter, native libraries, and application files into an EXE or an adjacent distribution directory. Bundled bytecode can often be extracted or inspected, so an EXE is not dependable source-code protection.

Build separately for each target operating system: a Windows EXE does not run natively on macOS or Linux. Build for a compatible Windows architecture, and install compiled dependencies for the same Python version and architecture before packaging. A 64-bit build generally cannot run on 32-bit Windows.

One-file applications can launch more slowly because they unpack at startup and may produce false-positive antivirus warnings. Code-signing with a trusted certificate can reduce Windows security warnings but cannot guarantee antivirus acceptance. Include a license and dependency notices when required by the packages bundled in the application.

PY vs EXE: format comparison

How the PY and EXE formats compare on the properties that matter most for this conversion.

Comparison of the PY and EXE file formats
Property .PY Python source file .EXE Portable Executable
Open standard Yes No
Compression Uncompressed Uncompressed
Typical file size Small Large
Opens in a web browser No No
Further editing Easy Not directly editable
Metadata support None Extensive
Plain-text readable Yes No
Best used for Editing and post-production Embedding in applications
Introduced 1991 1993
Developer Python Software Foundation Microsoft
MIME type text/x-python —

Information about file extensions and file types is provided by File-Extensions.org

Additional formats for
py file conversion

Reverse conversion

Convert to exe from
other formats

Share on social media:

Already downloaded

This file has already been downloaded. For your privacy it was deleted from our server right after the download, so it cannot be downloaded again. To get it once more, convert the file again.