Install Python
To write your own Python programs you need the Python interpreter on your computer. This lesson installs it on Windows, macOS or Linux, checks that it works, and runs your first script.
- Install Python 3 on your OS
- Check the installed version
- Use the interactive shell
- Run a .py file from the terminal
Check whether Python is already installed
Open a terminal (Command Prompt or PowerShell on Windows, Terminal on macOS and Linux) and run:
$ python --versionPython 3.15.1If you see a version number that starts with 3, Python is ready and you can skip to the interactive shell.
On macOS and Linux the command may be python3 instead of python. On Windows, the py launcher (py --version) is installed alongside Python and picks the newest version for you.
Install Python on Windows
- Go to python.org, open Downloads and download the latest Python 3 installer for Windows.
- Run the installer. On the first screen tick Add python.exe to PATH. This lets you type
pythonin any terminal. - Click Install Now and wait for it to finish.
- Close and reopen your terminal, then run
python --versionagain.
If python opens the Microsoft Store instead of printing a version, PATH was not set. Re-run the installer, choose Modify, and tick Add Python to environment variables, or turn off the “App execution aliases” for python.exe in Windows Settings.
Install Python on macOS
- Download the macOS installer from python.org and run the
.pkgfile, or install with Homebrew:brew install python. - Open Terminal and run
python3 --version.
Install Python on Linux
Most Linux distributions already include Python 3. If yours does not, install it with the package manager:
- Ubuntu or Debian:
sudo apt install python3 python3-pip python3-venv - Fedora:
sudo dnf install python3
The interactive shell (REPL)
Type python on its own to start the interactive shell. It shows a >>> prompt, runs each line as soon as you press Enter and prints the result:
>>> 2 + 35>>> "py" * 3'pypypy'>>> exit()The shell is perfect for trying one line. For anything longer, write a file.
Run your first Python file
Create a file called hello.py in any folder with this content:
print("Hello from a Python file!")print("2 to the power 10 is", 2 ** 10)Hello from a Python file! 2 to the power 10 is 1024
Then run it from a terminal opened in that folder:
$ python hello.pyHello from a Python file!2 to the power 10 is 1024Python files always end in .py. Keep each practice program in its own file with a descriptive name such as list_sum.py, so you can find and re-run it later.
Install packages with pip
pip installs extra packages from PyPI, the Python Package Index. It comes with Python. Check that it works:
$ python -m pip --versionpip 26.2.2 from C:\Python3\Lib\site-packages\pip (python 3.15)You install a package with python -m pip install <name>, for example python -m pip install requests. The Modules & pip lesson covers this in detail, including virtual environments.
Check your understanding
Quick quiz
1. Which installer option lets you type python in any Windows terminal?
PATH is the list of folders Windows searches for commands. Adding Python to it makes python work everywhere.
2. What does the >>> prompt mean?
>>> is the REPL prompt. Each line you type there runs immediately.
3. Which command installs a package?
pip install (run through python -m pip to be sure it uses the right Python) downloads the package from PyPI.
Program Practice
With Python installed, write each basic program in its own .py file and run it from the terminal.
40 Python Basic Programs
Every program has a step-by-step explanation, colour-coded code and its real output.
Install Python FAQ
Which Python version should I install?
Install the newest Python 3 release from python.org. Libraries add support for new versions quickly, and every example in this tutorial works on current Python 3.
What is the difference between python and python3?
They are names for the interpreter. On Windows the command is usually python (or py). On macOS and many Linux systems python3 is the Python 3 interpreter and python may not exist.
Do I need an IDE to write Python?
No. Any text editor and a terminal are enough. An IDE such as PyCharm or VS Code adds autocomplete, debugging and a run button. See PyCharm & VS Code Setup.
How do I uninstall Python on Windows?
Open Settings > Apps > Installed apps, find Python 3.x and click Uninstall. Remove the Python Launcher the same way if you want it gone too.