Installing Python
To install Python on Windows or macOS, download it from python.org and install it. On Linux, use your system's package manager, such as apt on Ubuntu and Debian. Then confirm it worked in a new terminal with python --version on Windows or python3 --version on macOS and Linux.
Key facts
- Python is free and open source, and the download on python.org is the official one.
- This course uses Python 3.14, and any 3.14 build works for it.
- On macOS and Linux the command is often
python3, becausepythonmay be missing or point at an old version. - Nothing in this course requires installing Python. Every lesson runs Python in your browser, so you can do this step later.
How do I install Python on Windows 10 or 11?
Install the Python install manager from python.org/downloads, then use it to get Python 3.14. It is the download python.org recommends for Windows, and it adds the python and py commands for you.
- Download. On a Windows PC, the main button on python.org/downloads reads "Download Python install manager". The same app is in the Microsoft Store.
- Install it. Open the downloaded
.msixfile and choose Install. - Install Python 3.14. Open a new terminal (search for "Terminal" or "PowerShell" in the Start menu) and run
py install 3.14. If the install manager offers to add a folder to your PATH, the list of folders a terminal searches for commands, you can accept.pythonandpywork either way, and the folder also makes commands such aspipavailable. - Check it. Run
python --version. A terminal that was already open before the install may not find the new commands, so use a new one.
py install 3.14
python --version
Python prints its version number, something like Python 3.14.7. The last number changes with each bug-fix release, and any 3.14 is fine. py list shows every version the install manager has installed.
python.org still links a standalone installer for 3.14 under the main button. If you use it, check "Add python.exe to PATH" at the bottom of the first screen, because it is off by default and the python command will not be found without it. The standalone installer is deprecated and will not be produced for Python 3.16 or later.
How do I install Python on macOS?
Download the macOS installer from python.org/downloads, open the .pkg file and click through it. The installer puts a python3 command on your PATH for you, so there is no box to check. To finish, double-click Install Certificates.command in the Python 3.14 folder inside Applications, as the Python docs instruct.
python3 --version
Use python3, not python, on a Mac. Recent versions of macOS ship without a python command at all, and older ones pointed it at Python 2, which this course does not use. A Mac with Apple's developer tools can also have Apple's own older python3, so check that python3 --version reports 3.14. If you already use Homebrew, brew install python also gives you a python3 command.
How do I install Python on Linux?
Most Linux distributions already have Python 3, because parts of the system are written in it. Check first, then install only if it is missing.
python3 --version
On Ubuntu and Debian the package is called python3, and python3-pip adds pip, the tool you will later use to add libraries.
sudo apt install python3 python3-pip
Fedora uses sudo dnf install python3 python3-pip, and Arch uses sudo pacman -S python python-pip.
The version your distribution ships can be several releases behind 3.14. Ubuntu 22.04 has Python 3.10, Ubuntu 24.04 has 3.12 and Ubuntu 26.04 has 3.14, while Debian 12 has 3.11 and Debian 13 has 3.13. This course is written for 3.14. Older versions word some error messages differently, and the match statement needs at least 3.10.
How do I run a Python file?
Save the code in a file that ends in .py and run that file from a terminal. The simplest way is to open a terminal in the folder that holds the file.
- Create a folder for your practice files, for example
python-lessonson your desktop. - Inside it, create a file called
hello.pyin a plain text editor and put this line in it. Notepad works, and so does TextEdit once it is set to plain text with smart quotes off.
print("Hello from a file!")Hello from a file!
- Open a terminal in that folder. On Windows, type
cmdinto the folder's address bar in File Explorer and press Enter. On macOS, open the folder in Finder, Control-click its name in the path bar at the bottom of the window, and choose Open in Terminal. Choose View, then Show Path Bar, if the path bar is hidden. On Linux, right-click inside the folder and look for Open in Terminal. - Run the file.
python hello.py
On macOS and Linux, type python3 hello.py instead. Either way, Python prints Hello from a file! and exits.
Which code editor should I use for Python?
Any plain text editor works, so Notepad will get you through the first lessons.
TextEdit on a Mac works too. Choose Format, then Make Plain Text. Then choose Edit, then Substitutions, and turn off Smart Quotes, because curly quotes break Python code. To make these the default, choose TextEdit, then Settings, and on the New Document tab select Plain text and turn off Smart quotes.
When you want line numbers, coloring and a run button, install Visual Studio Code and add its Python extension from the Extensions view. Open your folder in it, open hello.py, and the run button appears at the top right of the editor. The program's output shows in the integrated terminal at the bottom.
Python from python.org also comes with a small editor called IDLE. It is basic, but it is already there, and it runs code with F5.
Common mistakes when installing Python
Each of these six problems with installing Python has a short fix.
- 'python' is not recognized as an internal or external command (in PowerShell, "The term 'python' is not recognized as the name of a cmdlet"). Windows cannot find Python. Install the Python install manager. If you used the standalone installer instead, run it again, choose Modify, click Next, turn on "Add Python to environment variables" and click Install. Then open a new terminal.
- py install shows a "can't open file" error. An older Python launcher ran instead of the install manager. Click Start, open Installed apps, uninstall "Python launcher", and run the command again.
- Typing python opens the Microsoft Store or says "Python was not found". Windows includes a python shortcut that points to the Store until Python is installed. Install the Python install manager, then check that its Python aliases are on under "Manage app execution aliases" in the Start menu.
- command not found: python on a Mac. Use
python3. Apple stopped shipping apythoncommand. - The version printed is 2.7. An old system Python answered. Use
python3, and check withpython3 --version. - The terminal was open before the install. It keeps the old PATH. Close it and open a new one.
Exercise
Every Python installation can report its own version. Complete the program so it prints the major version number of the Python running it, which is the first number of the version. The first line, import sys, loads sys, a set of tools that ships with Python, and sys.version_info.major holds the number you need.
import sys
print()
3
Show the solution
import sys
print(sys.version_info.major)
Quiz
This quiz has 5 questions. Pick an answer to see why it is right or wrong.
-
1Which command shows the installed Python version on Windows?
The --version flag makes Python print its version and exit. On macOS and Linux the command is usually python3 --version, and py --help prints the command-line options, not the version.
-
2What does "Add python.exe to PATH" do in the standalone Windows installer?
PATH is the list of folders a terminal searches for commands. Without the entry, typing python finds nothing, or opens the Microsoft Store placeholder.
-
3On a Mac with Python from python.org, which command runs hello.py?
The python.org installer for macOS provides python3, not python, and recent macOS has no python command of its own. Windows uses python.
-
4What does this program print on a Python 3.14 install?
import sys print(sys.version_info.major)version_info.major is the first number of the version, and every Python 3 release gives 3, whatever the minor version.
-
5Which file extension does a Python program use?
Python files end in .py. The contents are plain text, so any plain text editor can create them.