Installing and Checking Python
Before you can run Python on your own computer, you need a Python program installed. That program reads Python code and runs it.
Many systems already include Python. Some do not. The exact installation method depends on the operating system, so this page focuses on checks that are stable across macOS, Windows, and Linux.
If this page feels too technical on a first pass, do not stop the book here. You can continue with the browser examples and return when you are ready to run Python locally.
Check the Version
First find a command that starts Python 3.
On macOS or Linux, open a terminal and try:
python3 --version
On Windows, open PowerShell and try:
py -3 --version
If that does not work, try:
python --version
A working installation prints a version, such as:
Python 3.12.6
The exact number may differ. For this course, the important part is that the
version starts with Python 3.
Use the command that works on your machine. In later examples, when you see
python3, Windows users may need to type py -3 or python instead.
Why Version Matters
Python 2 and Python 3 are different languages in important ways. Modern scientific Python uses Python 3.
If a command prints something like Python 2.7, do not use that command for
this course. Try another command, or install a current Python 3 runtime.
Check the Command Path
You can also ask the terminal where the command comes from.
On macOS or Linux:
command -v python3
Example output:
/usr/bin/python3
On Windows PowerShell:
Get-Command py
If you use python on Windows, check that command instead:
Get-Command python
The path is useful when two Python installations exist. That can happen after installing editors, package managers, or scientific Python tools.
Keep the Command Consistent
This course often writes commands with python3 because that is common on
macOS and Linux:
python3 hello.py
On Windows, the same run may be:
py -3 hello.py
Both commands ask Python 3 to run hello.py. The command name differs; the
Python code inside the file is the same.
Packages Come Later
Do not start by installing every package. In the first chapters, plain Python is enough. Later, we will add NumPy and Matplotlib deliberately, after lists, functions, and files are familiar.
The habit is:
- check Python
- run a tiny program
- add packages only when the lesson needs them
When the Command Is Missing
If macOS or Linux says:
command not found: python
or Windows says:
'python' is not recognized as an internal or external command
it does not mean your code is wrong. It means the terminal cannot find a Python command with that name.
Try the other command for your system:
- macOS or Linux:
python3 --version - Windows:
py -3 --versionorpython --version
If none of them prints Python 3, install Python 3 and reopen the terminal.
A Safe Installation Path
You can keep using the browser examples while you set up local Python. When you are ready, use an official or operating-system-managed source:
- Windows or macOS: start at python.org/downloads and choose a stable Python 3 release for your system.
- Linux: use your distribution's package instructions. Python may already be installed, and the package name and command differ between distributions.
Avoid copying an installation command from an unknown page. Installation instructions change over time; the official download page and your operating system's documentation are the durable sources.
After installation:
- close and reopen the terminal
- run the version check for your system
- confirm that the output begins with
Python 3
You do not need to choose an editor or install NumPy yet. The next page uses one
plain-text .py file.
Which output is acceptable for this course?
Select one choice, then check.
HintRead the major version
In Python 3.12.6, the first number after the word Python is the major
version.
SolutionChoose Python 3
Python 3.12.6 is acceptable because its major version is 3. The exact
minor and patch numbers may differ on your computer.
The Setup You Need
You do not need a complicated setup to begin. You need one Python 3 command that prints a version and can run a small script. Keep using that command until there is a reason to change it.