How to open a .py file
Quick, free ways to open Python on any system.
A .py file is a Python Source File. If double-clicking does nothing, your computer simply does not have an app that reads Python yet. Here is how to fix that on each operating system, using free software wherever possible.
Open a .py file step by step
- Confirm the file really is a .py. Drop it into the WhatFileType file identifier, which reads its signature without uploading anything.
- On Windows, open it with VS Code or PyCharm.
- On Mac, use VS Code or PyCharm.
- On Linux, try VS Code or vim.
- Still stuck? Convert the .py to pyc, which opens more widely.
Best apps to open .py files
Windows
- VS Code
- PyCharm
- IDLE
- any text editor
macOS
- VS Code
- PyCharm
- any text editor
Linux
- VS Code
- vim
- any text editor
!
Before you open it: Caution. A .py file is a program: running it executes whatever it contains. Read code from unknown sources before running it.
Frequently asked questions
Why can't I open my .py file?
Almost always because no installed app understands Python. Install one of the apps above, or convert the file to a format your existing software already reads.
How do I run a .py file?
From a terminal, run python file.py (or python3 file.py). Double-clicking may just open it in an editor, depending on your setup.
How do I open a .py file to read it?
Any text editor works. VS Code or PyCharm add syntax highlighting and let you run and debug the code.