Coding

How to Open Python on Windows, macOS and Linux

To open Python, open a terminal and type python on Windows or python3 on macOS and Linux, then press Enter. A banner appears and the prompt changes to >>>, which means Python is waiting for your code.

If you would rather not use a terminal, IDLE is a window-based way to get the same prompt. Both routes are covered below, along with how to leave Python again and what to do when the command is not found. This article assumes Python is already installed. If it is not, see how to install Python on Windows first.

Which command opens Python on your system

SystemCommand to typeNotes
Windowspython or pyThe Python documentation recommends py whenever several versions are installed.
macOSpython3A versioned name such as python3.15 also works.
Linuxpython3Python is preinstalled on most distributions.

On Unix-like systems the 3 matters. The official tutorial shows the interpreter started with a versioned command, python3.15, and the macOS documentation says to invoke python3.15 or python3. A plain python command may not exist on your machine, so python3 is the safe habit there.

How to open Python on Windows

Open Command Prompt, PowerShell or Windows Terminal. Type:

python

or:

py

According to the Python documentation, the global python command can be used from any terminal to launch your latest version of Python, and py launches your default interpreter. The documentation recommends py for any situation with more than one runtime installed, because you can pick a version with it:

py list
py -V:3.15

py list shows the installed runtimes. -V: followed by a tag launches that specific one, and it must come before any other option. For example, py -V:3.15 opens Python 3.15 if you have it installed.

The install manager also creates Start menu shortcuts, so you can search for Python from the Start menu as well. The exact entries depend on how you installed Python, so the terminal commands above are the dependable route.

If you have never installed a runtime, the documentation says any launch command tries to install the requested version and launch it. If no version is requested, the current latest release is installed automatically. This is controlled by a setting, so on a managed machine it may be turned off.

If python opens the Microsoft Store or reports that the command is not found, see Python and app execution aliases on Windows.

How to open Python on macOS

Open the Terminal app. Type:

python3

To check which version you are about to get without entering the prompt, the macOS documentation suggests:

python3.15 -VV

Replace 3.15 with the version you installed. The python.org installer places symlinks to the executable in /usr/local/bin/.

macOS also ships its own python3 at /usr/bin/python3. The documentation describes it as a usually older and incomplete version provided for the Apple development tools, Xcode or the Command Line Tools for Xcode, and says you should never modify or delete it. To see which one your terminal opens, run:

which python3

A path under /Library/Frameworks/Python.framework or /usr/local/bin means the python.org version. A path of /usr/bin/python3 means the system one.

Without a terminal: the python.org installer creates a Python 3.15 folder (the number matches the version you installed) in your Applications folder. It contains IDLE and Python Launcher. IDLE gives you an interpreter window, as described below. Python Launcher is for double-clicking scripts in Finder, not for typing code.

How to open Python on Linux

Open your terminal application and type:

python3

The Python documentation says Python comes preinstalled on most Linux distributions and is available as a package on all others. If python3 reports that the command is not found, install Python through your distribution's package manager. The documentation does not list one install command for every distribution, but it links to packaging guides for Debian, openSUSE, Fedora and Slackware. Check the package name for your distribution there.

What you see when Python opens

The interpreter prints a banner with its version and then shows the primary prompt. The official tutorial describes the primary prompt as usually three greater-than signs, and the secondary prompt for continuation lines as three dots. Example output (the version and build details on your machine will differ):

Python 3.15.2 (main, Nov  3 2026, 10:00:00) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Type a statement and press Enter. Python runs it at once and shows the result:

>>> 2 + 3
5
>>> print("Hello")
Hello

A statement that starts a block, such as if or for, makes Python show the ... prompt for the lines that belong to it. Indent those lines, then press Enter on an empty line to run the block.

How to exit Python

Type this at the >>> prompt:

quit()

The tutorial also documents the end-of-file keystroke: Control-D on Unix (macOS and Linux) and Control-Z on Windows, both at the primary prompt. It makes the interpreter exit with a zero exit status. On Windows, press Ctrl+Z and then Enter. The tutorial lists quit() as the fallback if the keystroke does not work. Both only work at the prompt. If Python is busy running something, that is a different situation, and Ctrl+C is the usual way to interrupt it.

How to open Python with IDLE (no terminal)

IDLE is, in the macOS documentation's words, a basic editor and interpreter environment that is included with the standard distribution of Python. Its Shell window behaves like the interactive interpreter. The IDLE documentation adds that it can enter, edit and recall complete statements, which most terminals cannot do, since they handle one physical line at a time.

  • macOS: open the Python 3.15 folder in Applications and open IDLE.
  • Windows: search for IDLE in the Start menu. The Python documentation for the install manager does not describe a dedicated IDLE shortcut, so if you cannot find one, use the command below.
  • Any system, from a terminal: run the module form, which the IDLE documentation lists as python -m idlelib. Use python3 -m idlelib on macOS and Linux.
  • Linux: IDLE may not come with Python. The documentation gives these packages: sudo apt install idle on Debian and Ubuntu, sudo dnf install python3-idle on Fedora, RHEL and CentOS, sudo zypper install python3-idle on SUSE and openSUSE, and sudo apk add python3-idle on Alpine.

IDLE can also hold a file. Choose File > New File to open an editor window, write your code there, then use Run > Run Module (F5). The IDLE documentation says this checks the module, restarts the shell to give a clean environment, runs the module, and shows the output in the Shell window.

Open Python and run a file instead

Typing the command with no file name opens the interactive prompt. Typing it with a file name runs that script. The tutorial says that when the interpreter is called with a file name argument, it reads and executes a script from that file:

python3 myscript.py

Two more forms are useful. -c runs a statement given on the command line, and the tutorial advises quoting the whole command:

python -c 'print("Hello")'

-i placed before a script file runs the script and then leaves you at the interactive prompt, with the script's variables still available to inspect:

python -i myscript.py

For a first script to try, see Hello World in Python. If you prefer an editor with a Run button, running Python scripts in VS Code covers that.

If Python will not open

"python is not recognized" or "command not found"

The terminal cannot find the program. On Windows, try py instead of python, and check that the Python entries under Manage app execution aliases are enabled, which is the fix the Python documentation gives. On macOS and Linux, try python3 instead of python. If neither works, Python is probably not installed, or its directory is not on PATH. Open a new terminal window after installing, because an already open one may not see the change.

The wrong version opens

Several copies of Python can coexist. On Windows, py list shows them and py -V:3.15 picks one. On macOS, which python3 tells you whether you are on the system copy or the python.org copy. Inside any prompt, you can read the active version from the banner, or run import sys; print(sys.version).

You typed a shell command at the >>> prompt

Commands such as pip install requests or cd folder belong in the terminal, not inside Python. At the >>> prompt they produce a SyntaxError. Exit with quit() first, then run them at the normal shell prompt.

Frequently asked questions

How do I open Python in the command prompt?
Open Command Prompt or PowerShell and type python or py, then press Enter. If Python is installed, a banner appears and the prompt changes to >>>. Type quit() to leave. If the command is not found, check that Python is installed and that the Python app execution aliases are enabled in Windows settings.
How do I open Python on a Mac?
Open the Terminal app and type python3, then press Enter. The Python documentation for macOS says to invoke python3 or a versioned name such as python3.15. If you installed Python from python.org, IDLE is also available in the Python folder inside Applications.
How do I open Python on Linux?
Open a terminal and type python3. According to the Python documentation, Python comes preinstalled on most Linux distributions and is available as a package on the others. Type quit() or press Ctrl+D to exit.
What is the difference between opening Python and running a Python file?
Typing python with no file name starts the interactive interpreter, which runs one statement at a time. Typing python followed by a file name, such as python myscript.py, reads and runs that whole script and then returns you to the shell.
How do I open Python without a terminal?
Use IDLE, the editor and interpreter that ships with the standard Python distribution on Windows and macOS. Its Shell window works like the interactive interpreter. On some Linux distributions IDLE is a separate package, for example idle on Debian and Ubuntu.

Sources