You’ll now learn to open Python on Linux, Windows, and MacOS. First of all, you should know that there are two ways of using Python:
- Start an interactive shell, also called a REPL, short for read-evaluate-print-loop.
- Start a Python program that you stored in one or more files with the .py extension.
This tutorial will start with the interactive shell because it’s ideal for exploring the language. But at some point, using the REPL will not be enough, and you’ll have to start creating Python files instead.
If you installed Python on your local machine, you first need to start a terminal or command prompt before you can start the Python interactive shell. On macOS and Linux, the command is usually python3 (or sometimes just python). On Windows, it’s python or py. If you’re not sure which version you get, check your Python version.
Want to get started without opening a terminal? Try your first Python exercise in your browser on our free learning platform. There’s nothing to install, and you can return to the setup instructions whenever you’re ready.
How to open Python on Windows
On Windows, you can start Python from a terminal. I assume you installed Python with the Python install manager, which is the recommended way since Python 3.14. If you haven’t installed Python yet, follow the installation instructions first.
To start a terminal, hit the Windows key and start typing Terminal or PowerShell. The older ‘Command Prompt’ program works too. Once you are in a terminal, enter one of these commands:
pythonpy
With the install manager, both commands start the latest Python version you have installed. The py command does more: py list shows which Python versions you have installed, and py install 3.14 installs another version next to the one you have. In this tutorial, I’ll often write python3, because that’s what works on macOS and Linux. On Windows, type python or py instead.
If python opens the Microsoft Store instead of starting Python, the Python install manager isn’t installed yet. Go back to the installation page and install it first.

How to open Python on Mac
On MacOS, search for a program called terminal. You can do so by pressing the command key (⌘) + space bar. This will open up the Spotlight search bar, in which you start typing the word ‘terminal’.
Once inside the terminal, enter python3 to open the Python REPL. If that doesn’t work, try entering python instead (without the 3).
How to open Python on Linux
On Linux, you first need to start a terminal. This can often be done with the shortcut ctrl + alt + T. Alternatively, you can search for the terminal program in your start menu. The name and where to find it differ from distribution to distribution. Once you have a terminal running, enter python3 to start the Python REPL. If that doesn’t work, try python instead (without the 3).

How to close the REPL
Now that you know how to open the REPL, it would be nice to close it properly, too. If you simply close the terminal window by pressing the close button, you will be able to close the REPL inside it as well. However, it won’t be a clean exit; your terminal will usually warn you about this. So, how do you exit the REPL cleanly?
On Python 3.13 and newer, you can simply type exit or quit and press enter. On older versions, you need to call it as a function: exit(). That form still works everywhere, so if you’re not sure which version you have, use exit().
You can also use a little trick if you’re on Linux or MacOS. By pressing control + d, the REPL will exit immediately. Control + d sends the ‘end of file’ character to the terminal, and the REPL interprets this as a request to exit Python. On Windows, you can do something similar by pressing control + z and then hitting enter.
How to run a Python file
The REPL is great for trying things out, but anything you type in it is gone once you close it. For real programs, you store your code in a file with the .py extension and ask Python to run that file. This is the second way of using Python from the start of this page.
Let’s try it. Create a file called hello.py with any plain text editor (not a word processor like Word) and put this line in it:
print("Hello from a Python file!")Code language: Python (python)
Now open a terminal, go to the folder where you saved the file with the cd command, and run it. On macOS and Linux:
$ python3 hello.py
Hello from a Python file!Code language: Python (python)
On Windows, use python hello.py or py hello.py. Python runs the file from top to bottom and then exits. You don’t end up in the REPL.
If you get an error saying the file can’t be found, you’re probably in the wrong folder. Use cd to go to the folder that contains hello.py, or give the full path to the file.
Writing programs in a plain text editor gets old quickly, though. In the chapter on creating Python programs, I’ll show you how to set up a proper editor (VSCode) and run your programs from there.