Ready to dive into coding on your Mac? Python is one of the most beginner-friendly and powerful programming languages out there, and macOS makes a great platform to get started. Whether you’re new to programming or just setting up your development environment, this guide will walk you through installing Python on macOS and writing your very first “Hello, World!” program. In just a few steps, you’ll go from zero to running code in your terminal — no prior experience needed. Let’s get your Mac talking Python!
Check If Python Is Already Installed
Open Terminal
- Press
Cmd + Space
to open Spotlight - Type “Terminal” and hit Enter
Check the Python Version
Type this command and press Enter:
python3 --version
If Python is installed, you’ll see something like:
Python 3.11.5
If you get an error, don’t worry—just follow the next step to install it.
Installing Python on macOS
Download Python
Go to the official site: python.org/downloads
Click Download Python for macOS.
Run the Installer
- Open the
.pkg
file you downloaded - Follow the on-screen instructions
- Python and pip (Python’s package manager) will be installed
Verify pip
Open Terminal and type:
pip3 --version
You should see something like:
pip 23.2.1 from ...
Install Visual Studio Code (VS Code)
Download VS Code
Click “Download for macOS”.
Install VS Code
- Open the
.zip
file - Drag
Visual Studio Code.app
into your Applications folder
Enable Terminal Access
Open VS Code, press Cmd + Shift + P
, and type:
Shell Command: Install 'code' command in PATH
This lets you open VS Code from Terminal using:
code .
Set Up Python in VS Code
Install the Python Extension
- Click the Extensions icon (or press
Cmd + Shift + X
) - Search for “Python”
- Install the one by Microsoft
Select Your Python Interpreter
- Press
Cmd + Shift + P
- Type “Python: Select Interpreter”
- Choose the version you installed
Write & Run Your First Python Program
Create a New File
- Go to File > New File
- Save it as
hello.py
Write Your Code
Paste this into the file:
python
print("Hello, world!")
Run the Program
- Click the Run button
- Or right-click and choose “Run Python File in Terminal”
You should see:
Hello, world!
Congrats—you just ran your first Python program!
Troubleshooting Tips
- Python Not Found in VS Code Use “Python: Select Interpreter” and make sure Python is installed
- pip Not Working Try:bash
python3 -m ensurepip python3 -m pip install package_name
- Terminal Issues In VS Code, go to View > Terminal and click the trash icon to reset
- Multiple Python Versions Use
python3 --version
andwhich python3
to check. Uninstall older versions if needed - Virtual Environment Confusion Activate with:bash
source venv/bin/activate
- Syntax Errors Python is picky about spaces! VS Code helps catch these early
Pro Tips for Beginners
- Keep Python and VS Code updated
- Use virtual environments to keep projects organized
