Learn

Short lessons with real code you can edit and run on the page.

Installing Python

Optional Python 3.14 Runs in your browser Updated
In short

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, because python may 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.

  1. 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.
  2. Install it. Open the downloaded .msix file and choose Install.
  3. 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. python and py work either way, and the folder also makes commands such as pip available.
  4. 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.
Terminal
py install 3.14
Terminal
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.

Terminal
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.

Terminal
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.

Terminal
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.

  1. Create a folder for your practice files, for example python-lessons on your desktop.
  2. Inside it, create a file called hello.py in 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.
Python
print("Hello from a file!")
Output
Hello from a file!
  1. Open a terminal in that folder. On Windows, type cmd into 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.
  2. Run the file.
Terminal
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 a python command.
  • The version printed is 2.7. An old system Python answered. Use python3, and check with python3 --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.

Python
import sys

print()
Output
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.

  1. 1Which command shows the installed Python version on Windows?

  2. 2What does "Add python.exe to PATH" do in the standalone Windows installer?

  3. 3On a Mac with Python from python.org, which command runs hello.py?

  4. 4What does this program print on a Python 3.14 install?

    import sys
    print(sys.version_info.major)
  5. 5Which file extension does a Python program use?

Frequently asked questions

How do I install Python?
On Windows and macOS, download it from python.org and install it, and on Linux use your system's package manager, such as apt on Ubuntu and Debian. On Windows the download is the Python install manager, and py install 3.14 then fetches Python itself. Check it in a new terminal with python --version on Windows or python3 --version on macOS and Linux.
Can I install Python for free?
Yes. Python is free and open source, and the download on python.org has no paid version.
How do I install Python on Windows 11?
The same way as on Windows 10. Install the Python install manager from python.org or the Microsoft Store, run py install 3.14 in a new terminal, and check it with python --version.
What does pip install do in Python?
pip is the tool that installs extra libraries from the Python Package Index. For example, python -m pip install requests installs the requests library on Windows, and macOS and Linux use python3 in place of python. Many Linux distributions and Homebrew only allow pip inside a virtual environment, a private folder of libraries for one project.
Do I need to install Python to follow this course?
No. Every example on these pages runs in your browser. Installing Python lets you save programs as .py files and run them outside the browser.
Which version of Python should I install?
The newest 3.14 release on python.org. Any version from 3.10 up runs the examples in this course, though older versions word some error messages differently.