Getting Started with Python on macOS
Whether you're new to programming or an experienced coder, setting up Python on your macOS machine is the first step toward writing powerful Python code. This guide will walk you through the simple steps of installing Python on your mac operating system and ensuring that everything is ready for your coding journey.
Step 1: Download Python Installer
The first step is to download the latest version of Python. Here's how:
- Visit the official Python website: https://www.python.org/downloads/.
- On the homepage, you'll see a "Download" button that automatically suggests the version for your operating system. Click the button to start the download.
- If you want a specific version of Python, you can go to the 'Downloads' section and select the version manually.

Step 2: Run the Installer
After downloading the Python installer, follow these steps to complete the installation:
- Locate the downloaded file (usually in your Downloads folder). It will be named something like
python-3.x.x-macosx.pkg
. - Double-click the file to launch the installer, then follow the on-screen instructions to install Python.
- The installer will automatically install both Python and
pip
(Python’s package manager). - After installation is complete, open the Terminal application.
- In the Terminal, type the following command to verify that Python is installed:
python3 --version
python3 --version
If Python was installed correctly, you should see the installed version printed in the terminal, like:
Python 3.x.x
Python 3.x.x
✅ Tip: On macOS, Python 3 is typically accessed using python3
instead of just python
.
Step 3: Install a Code Editor
To write and run Python code, you'll need a code editor. While you can technically use any text editor (like TextEdit or Notepad), we recommend using a professional code editor to make your workflow easier and more efficient.
One of the most popular and beginner-friendly options is:
- Visual Studio Code (VS Code) – A lightweight, open-source code editor developed by Microsoft. It offers built-in Git integration, debugging tools, and excellent Python support via extensions.
How to Install Visual Studio Code:
- Go to https://code.visualstudio.com and click on the Download button for macOS.
- Open the downloaded file and drag VS Code into your Applications folder.
- Launch VS Code from your Applications folder or Spotlight.
Install the Python Extension:
- In VS Code, click on the Extensions icon on the left sidebar (it looks like a square with four small squares).
- In the search bar, type Python.
- Find the Python extension by Microsoft and click Install.

Step 4: Run Your First Python Script
It’s time to write and run your very first Python program! Just follow these simple steps:
- Open your code editor (such as Visual Studio Code).
- Create a new file and name it something like
hello.py
. Make sure the file extension is.py
, which stands for a Python file. - Inside the file, type the following code:python
print("Hello, world!")
print("Hello, world!")
- To run the script:
- If you're using VS Code, click the Run (▶️) button in the top-right corner of the editor.
- Or, open the Terminal in VS Code (or use the built-in macOS Terminal), navigate to the folder where your file is saved, and run:
python3 hello.py
python3 hello.py
- You should see this output:
Hello, world!
Hello, world!
- 🎉 Congratulations — you've just run your first Python program!
That's it! You’re all set to start coding in Python.
Happy coding!
Frequently Asked Questions
Is Python pre-installed on macOS?
Is Python pre-installed on macOS?
macOS comes with Python 2.x pre-installed, but most development requires Python 3, which you’ll need to install manually.
How do I check if Python 3 is installed on my Mac?
How do I check if Python 3 is installed on my Mac?
Open the Terminal and run python3 --version
. If installed, it will display the version number.
What’s the difference between python and python3 in Terminal?
What’s the difference between python and python3 in Terminal?
On macOS, python
often refers to Python 2.x, while python3
refers to the latest Python 3 installation.
Do I need to install pip separately on macOS?
Do I need to install pip separately on macOS?
No. When you install Python 3 using the official installer, pip
is installed automatically.
Can I use other code editors instead of VS Code?
Can I use other code editors instead of VS Code?
Absolutely! You can use editors like PyCharm, Sublime Text, or even Jupyter Notebooks. VS Code is recommended for its simplicity and extensions.