Install Python 3 and Run Your First Script
Check whether Python 3 is already installed, install it from official sources if it is not, and run a short script that prints the version.
Based on the official Python documentation. Date checked: November 27, 2026. Script tested on Python 3.13.5.
Series: Python for small scripts, Part 1 of 10. Previous: none (this is Part 1). Next: Part 2: Variables, Types, and print.
TL;DR
- Check first with
python3 --versionorpython --version. You want Python 3.11 or newer. - If it is missing, install it from official sources, then run the script below.
- You should see a greeting and a version line.
- This is Part 1 of 10.
Before you start
- A Windows, macOS, or Linux computer, a terminal, and a plain text editor.
- A new empty folder, for example one named
python-scripts. - Version tested: Python 3.13.5. Latest on python.org: 3.15.2 (October 25, 2026). Python 3.10 reached the end of support on October 1, 2026.
The finished script
Save this as hello.py in that folder:
import sys
print("Hello from Python.")
print("Version:", sys.version)
When you run it, you should see two lines. Your version text will differ:
Hello from Python.
Version: 3.13.5 (main, Aug 10 2026, 12:06:59) [GCC 14.2.0]
Steps
- See whether Python 3 is already there. Open a new terminal and run
python3 --version. If that fails, trypython --version. Why: many Linux and macOS systems already have apython3command. If it prints 3.11 or newer, skip the install. You should see: a line likePython 3.13.5. - Install only if the check failed, or if the version is 3.10 or older. Then close the terminal, open a new one, and repeat the check. Why: a new terminal picks up the updated command path. You should see:
Python 3.11or newer.- Windows: Install the Python install manager from python.org/downloads or the Microsoft Store, then open a new terminal and run
python. If no runtime is installed yet, that command installs the current latest release. You can also runpy install default. - macOS: Download the current
.pkginstaller from python.org, run it, then double-clickInstall Certificates.commandin/Applications/Python 3.15/(the folder name follows the version you installed). Usepython3. Do not delete Apple’s/usr/bin/python3. - Linux: Python is already installed on most distributions. If the version check passed, you are done. If not, use your distribution’s package manager (see the official Unix guide).
- Windows: Install the Python install manager from python.org/downloads or the Microsoft Store, then open a new terminal and run
- Create the folder and the file. Make a folder named
python-scriptsand save the script above ashello.py. Why: a dedicated folder keeps practice files together. You should see:hello.pyin that folder. - Run the script. Change into
python-scriptsand runpython3 hello.py. On Windows, usepython hello.py. Why: this asks the interpreter to read the file and run it. You should see: the two-line output shown above, with your version on the second line.
If it fails
python3: command not foundor'python' is not recognized. The terminal cannot find an interpreter. Install from the official source for your system, open a new terminal, and run the version check again.Python was not found; run without arguments to install from the Microsoft Store. Windows may be offering a Store alias, not a real install. Install the Python install manager from python.org or the Store, then open a new terminal.python3: can't open file '.../hello.py': [Errno 2] No such file or directory. You are in the wrong folder, or the filename differs. Runls(macOS or Linux) ordir(Windows) and confirm you seehello.py.- The version is 2.7, or a macOS system Python you did not install. Use
python3from a python.org install. Leave Apple’s/usr/bin/python3alone.
Stay safe
- Download Python only from python.org, the Microsoft Store Python install manager, or your OS package manager. Skip unrelated “free Python” installers, and do not pipe a random download into a shell.
- Work in a folder you created. Do not replace or delete the system Python on macOS or Linux.
Next
Part 2: Variables, Types, and print
Sources
- Python Software Foundation, Download Python, checked November 27, 2026 (latest: 3.15.2, October 25, 2026; 3.10 end of support: October 1, 2026).
- Python 3.15.2 docs, checked November 27, 2026: Windows, macOS, Unix, and the interpreter.
Spot something wrong or outdated? Leave a comment below. Every comment is reviewed to keep these posts accurate.
By commenting, you agree to our Terms of use and confirm this is your own work. Short quotes are fine with a credit and link. Copied, unsafe, or abusive comments are removed. See something copied? Say so here.