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:

  1. Visit the official Python website: https://www.python.org/downloads/.
  2. 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.
  3. If you want a specific version of Python, you can go to the 'Downloads' section and select the version manually.
official python downloads page

Step 2: Run the Installer

After downloading the Python installer, follow these steps to complete the installation:

  1. Locate the downloaded file (usually in your Downloads folder). It will be named something like python-3.x.x-macosx.pkg.
  2. Double-click the file to launch the installer, then follow the on-screen instructions to install Python.
  3. The installer will automatically install both Python and pip (Python’s package manager).
  4. After installation is complete, open the Terminal application.
  5. In the Terminal, type the following command to verify that Python is installed:
python3 --version

If Python was installed correctly, you should see the installed version printed in the terminal, like:

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:

  1. Go to https://code.visualstudio.com and click on the Download button for macOS.
  2. Open the downloaded file and drag VS Code into your Applications folder.
  3. Launch VS Code from your Applications folder or Spotlight.

Install the Python Extension:

  1. In VS Code, click on the Extensions icon on the left sidebar (it looks like a square with four small squares).
  2. In the search bar, type Python.
  3. Find the Python extension by Microsoft and click Install.
Python extension in VS Code

Step 4: Run Your First Python Script

It’s time to write and run your very first Python program! Just follow these simple steps:

  1. Open your code editor (such as Visual Studio Code).
  2. Create a new file and name it something like hello.py. Make sure the file extension is .py, which stands for a Python file.
  3. Inside the file, type the following code:
    python
    print("Hello, world!")
  4. 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
  5. You should see this output:
    Hello, world!
  6. 🎉 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?

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?

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?

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?

No. When you install Python 3 using the official installer, pip is installed automatically.


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.