What is the PYW file format?
A .pyw file is a Python source script that runs without opening a console window on Windows. Syntactically it is identical to a standard .py file - valid UTF-8 Python source code. The distinction is entirely in the extension: Windows associates .pyw with pythonw.exe, the windowless Python interpreter, rather than the standard python.exe. When a .pyw file is launched, no terminal window appears, making it ideal for GUI applications built with tkinter, wxPython, or PyQt/PySide, and for silent background scripts.
The .pyw convention was established alongside the early CPython Win32 ports in the mid-1990s and was formalised by PEP 397 (Python Launcher for Windows), included with Python since version 3.3. The Python Launcher (py.exe / pyw.exe) reads the file extension to select the appropriate interpreter.
On macOS, some Python distributions supply a pythonw binary for Aqua GUI integration, but .pyw is less commonly used there. On Linux the extension carries no special meaning - console suppression is handled by nohup, process detaching, or the GUI toolkit itself.
A .pyw file may begin with a shebang (#!/usr/bin/env python3) or a coding declaration (# -*- coding: utf-8 -*-), but neither is required. Renaming any .pyw to .py and running it with python.exe always works; a console window will appear in that case.
Security & safety
RISK: MEDIUMA .pyw file is executable Python code that runs silently without a console window, making malicious scripts harder to detect (no visible terminal). Treat .pyw files from unknown sources the same as any unknown executable. Review the source code in a text editor before running. Python must be installed for the file to execute; without Python the file is harmless.
Format details
in a nutshellPrograms that open PYW files
Technical details
deep spec| Execution on Windows | Launched by `pythonw.exe` - the windowless CPython interpreter; no console window is allocated or inherited |
| Syntax | Identical to `.py` - valid Python 3 (or Python 2) source code; the extension is the only functional distinction |
| Encoding | UTF-8 plain text; BOM permitted but not recommended (PEP 8) |
| Windows file-type registration | `.pyw` mapped to `pythonw.exe` via Windows registry (`HKEY_CLASSES_ROOT\.pyw`) |
| Python Launcher support | PEP 397 `py.exe` / `pyw.exe` dispatches `.pyw` files to the windowed launcher (Python 3.3+, Windows) |
| Console window | None - `pythonw.exe` discards stdout/stderr unless explicitly redirected to a file or pipe |
| Primary use case | GUI applications (`tkinter`, `wxPython`, `PyQt`/`PySide`) and silent background scripts |
| Magic bytes | None - plain UTF-8 text; optional shebang `#!/usr/bin/env python3` or coding declaration at line 1 |
| MIME type | `text/x-python`; also `application/x-python` |
| Platform | Windows (primary); macOS via `pythonw` binary (some distributions); Linux (extension carries no special meaning) |
| Typical file size | 1 KB - 1 MB (source code only) |
| Compatibility | Renaming `.pyw` to `.py` and running with `python.exe` always works; a console window will appear |
| Related format | `.py` - standard Python script; runs via `python.exe` on Windows, allocating a console window |
| Released | circa 1994 (Python for Windows; pythonw.exe introduced in early Win32 Python builds) |
| Latest version | Python 3.x (current 3.13.x as of 2025); no separate .pyw format version |
| Open standard | Yes · royalty-free |
| Specification | docs.python.org |
PYW conversions
Community Q&A
asked by usersNo questions yet - be the first to ask about PYW files.