Tutorial: Installing Python on Mac (2023)

Python is one of the most powerful programming languages, mostly used in data science, machine learning, and big data analytics. So, installing Python is essential for all programmers. As a novice programmer, you may be wondering how to install or update Python on your Mac properly. Here, we will walk through the different ways of installing and updating Python on macOS.

Then, to write and run our Python code in an integrated development environment (IDE), we will learn how to install and configure Visual Studio Code on Mac. There are different methods for installing and updating Python on Mac, but let's stick to the third principle of the Zen of Python that says: “Simple is better than complex.” Accordingly, we will try simple methods rather than complex ones. Before we jump into learning how to install or update Python on Mac, let's review what we're going to discuss in this tutorial:

  • Installing and updating Python on Mac
  • Installing Visual Studio Code on Mac
  • Running our first Python script on Mac

Installing and Updating Python on Mac

I have two pieces of news for you; one is good, the other bad. The good news is that for the sake of compatibility with legacy systems, Python 2.7 is pre-installed on your Mac, but the bad news is that Python 2.7 has been retired. Therefore, it isn't recommended for new developments. So, if you want to take advantage of the new Python version with its many features and improvements, you need to install the latest Python alongside the version that comes pre-installed on macOS. Before we start installing the latest version of Python, let’s see why there are different versions of the same programming language. All programming languages evolve by adding new features over time. The programming language developers announce these changes and improvements by increasing the version number.

Install Python 3 as a part of the Command Line Developer Tools

To check the current version of Python that is already installed, open the Terminal application by typing command + space and then spelling out terminal and hitting return. Now, type the following command, and then hit return to see that you have Python 2.7 pre-installed on your Mac:

% python --version
Python 2.7.18

Now, try the following command to check whether or not Python 3 is installed on your Mac:

~ % python3 --version

The following message will probably appear on the Terminal window,

xcode-select: note: no developer tools were found at '/Applications/Xcode.app', requesting install. Choose an option in the dialog to download the command line developer tools.

And alongside the Terminal window, a dialog box will automatically appear that says this command requires the command line developer tools. First, let’s identify the command-line developer tools. To put it briefly, the command line developer tools package is a set of tools mostly used in the development process. They help run specific commands, such as make, git, python3, etc. So, although there are other ways to install Python 3.x on Mac without installing the command line developer tools, I recommend you install it because it provides a string of tools for development on Mac. To install the package, click on the Install button, and follow the steps to complete the installation process. Once the installation process is complete, rerun the previous command. Yes, Python 3.x is installed on your Mac.

~ % python3 --version
Python 3.8.9

Install Python 3 with the Official Installer

Downloading the latest Python version from the official Python website (python.org) is the most common (and recommended) method for installing Python on a Mac. Let’s try it out.

1. First, download an installer package from the Python website. To do that, visit https://www.python.org/downloads/ on your Mac; it detects your operating system automatically and shows a big button for downloading the latest version of Python installer on your Mac. If it doesn't, click the macOS link and choose the latest Python release.
Tutorial: Installing Python on Mac (1)

2. Once the download is complete, double-click the package to start installing Python. The installer will walk you through a wizard to complete the installation, and in most cases, the default settings work well, so install it like the other applications on macOS. You may also have to enter your Mac password to let it know that you agree with installing Python.
Tutorial: Installing Python on Mac (2)

NOTE If you're using Apple M1 Mac, you need to install Rosetta. Rosetta enables Intel-based features to run on Apple silicon Macs.

3. When the installation completes, it will open up the Python folder.
Tutorial: Installing Python on Mac (3)

4. Let’s verify that the latest version of Python and IDLE installed correctly. To do that, double-click IDLE, which is the integrated development environment shipped with Python. If everything works correctly, IDLE shows the Python shell as follows:
Tutorial: Installing Python on Mac (4)

5. Let’s write a simple Python code and run it in IDLE. Type the following statement, and hit the return key.

print(“Hello, World!”)

Tutorial: Installing Python on Mac (5)

Or let’s do a basic calculation in Python as follows:
Tutorial: Installing Python on Mac (6)

NOTE The exciting advantage of this installation method is that you can easily update an outdated Python install by downloading the latest Python installer. The new version of Python is available on your Mac once the installation is complete.

Installing Visual Studio Code on Mac

Although we can use IDLE or the terminal application for writing Python scripts, we prefer to use a powerful, extensible, and lightweight code editor rather than rigid coding environments. In this part of the tutorial, we're going to install Visual Studio Code for Python development on macOS.

1. First, you need to download Visual Studio Code for macOS from its official website at https://code.visualstudio.com/.
Tutorial: Installing Python on Mac (7)
2. Double-click the downloaded file to extract the archived contents.
Tutorial: Installing Python on Mac (8)
3. Move the Visual Studio Code application to the Application folder to make it available in the macOS launchpad.
Tutorial: Installing Python on Mac (9)
4. Launch Visual Studio Code, and then open a folder where your Python scripts exist (or create a new one). For example, create a new folder on your Desktop, and name it py_scripts, then try to open the folder on VS Code. Usually, VS Code needs your permission to access files in your Desktop folder; click OK.
Tutorial: Installing Python on Mac (10)

Also, you may need to declare that you trust the authors of the files stored in your Desktop folder.
Tutorial: Installing Python on Mac (11)
5. Create a new file with a .py extension. For example, create a new file, and name it prog_01.py. VS Code detects the .py extension and wants to install a Python extension.
Tutorial: Installing Python on Mac (12)
To work with Python inside VS Code, we need to use the Python extension, which includes many useful features, such as code completion with IntelliSense, debugging, unit testing support, etc.

Install it by clicking on the Install button.
Tutorial: Installing Python on Mac (13)

We can also install the Python extension by browsing extensions. Click on the Extensions icon on the left side of VS Code.
Tutorial: Installing Python on Mac (14)

This will show you a list of the most popular VS Code extensions on the VS Code Marketplace. Now, we can select the Python extension and install it.
Tutorial: Installing Python on Mac (15)

6. Once the extension is installed, you have to select a Python interpreter. Click on the Select Python Interpreter button:
Tutorial: Installing Python on Mac (16)

Then select the recommended Python interpreter on the list.
Tutorial: Installing Python on Mac (17)

If you have multiple Python versions installed on your Mac, it's better to choose the latest version.
Tutorial: Installing Python on Mac (18)

You also can select a Python interpreter using the Python: Select Interpreter command from the Command Palette. To do so, press CMD + SHIFT + P, type Python, and choose Select Interpreter.

Running Our First Python Script on Mac

Excellent, we have everything we need to write and run our Python code inside VS Code. Let's write the following code in VS Code and then run it.

print("Hello, World!)name = input("What's your name? ")print("Hello {}!\nWelcome to Dataquest!".format(name))

Run the code by clicking the ▶️ button at the top right corner of VS Code. First, it shows Hello, World! in the integrated terminal, then it asks your name; enter your name, and hit return. It outputs Hello <your name,>, and writes Welcome to Dataquest!on the next line.

Tutorial: Installing Python on Mac (19)


In this tutorial, we learned how to install the latest version of Python on Mac, as well as updating an outdated Python version. Additionally, we learned how to install Visual Studio Code as a code editor and configure it for running Python scripts. Finally, we wrote a small Python script in VS Code and ran it successfully. In the next tutorial, we will learn about Python virtual environments and how to create and use them. Congratulations! From now on, the sky's the limit, and you can become a great Pythonista!

If you’d like to learn more about this topic, check out Dataquest's interactive Introduction to Python course, and our Data Analyst in Python, and Data Scientist in Python paths that will help you become job-ready in around 6 months.



What is the correct way to install Python on Mac? ›

The best place to install Python is from the official website. Go to Python.org and click on the Download button to download the latest version for MacOS. Go to your download folder and double-click on the python-<version>-macosx. pkg file to start the Python installer.

How to install Python step by step? ›

Installing Python on Windows takes a series of few easy steps.
  1. Step 1 − Select Version of Python to Install. ...
  2. Step 2 − Download Python Executable Installer. ...
  3. Step 3 − Run Executable Installer. ...
  4. Step 4 − Verify Python is installed on Windows. ...
  5. Step 5 − Verify Pip was installed.
Mar 10, 2021

What is the limitation of installing Python using Homebrew on Mac? ›

Limitations of Installing from Homebrew

The Python package for macOS that comes with Homebrew doesn't include the Tcl/Tk dependency required by the Tkinter module. Tkinter is the standard library for developing GUIs (graphical user interfaces) in Python, but it is not part of Python.

How do I start Python after installing Mac? ›

On a Mac system, it is very straightforward. All you need to do is open Launchpad and search for Terminal , and in the terminal, type Python , and it will give you an output with the Python version.

How to install Python and set path in Mac? ›

Steps for Adding Python to Path in Mac
  1. Open the Terminal on your MAC and give the following command: sudo nano /etc/paths. ...
  2. Enter your password. ...
  3. Now, after the last directory location, enter the path to the Python Install directory.
  4. Press Ctrl + X to quit and further, press Y to save the changes to the Path variable.
Jun 14, 2023

How to set Python to python3 Mac? ›

How to Make Python 3 the Default in MacOS
  1. From the Terminal, open zshrc in your text editor of choice, we'll use nano for the sake of ease:
  2. Add the following alias at the bottom of the .zshrc file:
  3. Hit Control-O and then Control-X to save the edit and then exit out of nano.
Feb 15, 2022

How to install Python on terminal? ›

Step 2: Install Python
  1. Open a terminal.
  2. Type pip3 and press Enter .
  3. You should see the help text from Python's pip package manager. If you get an error message running pip3 , then go through the install steps again to make sure you have a working installation.

How do I open Python after installing? ›

After installation, Python may be launched by finding it in Start. Alternatively, it will be available from any Command Prompt or PowerShell session by typing python . Further, pip and IDLE may be used by typing pip or idle . IDLE can also be found in Start.

Is it difficult to install Python? ›

One very popular and easy-to-learn language is Python. But knowing Python's syntax is not enough; you also need to know how to install Python on your computer, configure everything, and start creating your own new and brilliant projects. Fortunately, installing Python on Windows machines is not difficult.

How do I install Python installation? ›

Navigate to Control Panel. Click “Uninstall a program”, and a list of all the currently installed programs will display. Select the Python version that you want to uninstall, then click the “Uninstall” button above the list – this has to be done for every Python version installed on the system.

Why Python is not installing? ›

The Python setup may fail if you don't have Windows Service Pack 1 (SP1) installed on your computer. It is a requirement for installing Python. Download Windows Service Pack 1. If it states an unspecified error, try downloading KB2999226.

Does Python run well on Mac? ›

Learning to code is hugely popular at the moment, and Python is a great coding language to learn. Luckily for us, the Mac is a great coding platform, and Python makes it easy to learn how to code on a Mac.

Why doesn t Python work on Mac? ›

This guide will also teach you how to run your first Python script. While older Macs come with a built-in version of Python, it's outdated and no longer compatible with the latest applications. To run Python scripts on your Mac, you'll have to install the newest version of Python on your system manually.

Do I need XCode to install Python on Mac? ›

Python and XCode

While they are compatible and you can use them to improve your results, you're not required to use XCode when using Python.

Do I need to restart my computer after installing Python? ›

If you installed Python from the official Python website

You need to restart your machine afterward. In this case, the latest Python release will be installed on your computer but also the previous version will remain. If necessary, you can uninstall it manually using the Control Panel.

How to install Python on Mac without admin rights? ›

Install and use pip on macOS without sudo / admin access
  1. Run the installation, appending the --user flag; python ~/Downloads/get-pip.py --user . pip will be installed to ~/Library/Python/2.7/bin/pip.
  2. Make sure ~/Library/Python/2.7/bin is in your $PATH . For bash users, edit the PATH= line in ~/. ...
  3. Use pip!

How do I know which version of Python is installed on my Mac? ›

The command to check the version of Python you are running is the same for all three machines: python –version. You can enter this into the Mac, Linux terminal, Windows Command Prompt, or Power Shell. Type the command and hit Enter.

What is the default path for Python? ›

By default, Python installations on Windows are located in the C:\ directory or C:\Users\<User>\AppData\Local\Programs.

How do I know if Python is on path? ›

To see if Python is already added to the Windows PATH, open the terminal and type python --version, then hit the Enter key. If the command returns the currently installed version of Python, it means you've successfully added it to the Windows PATH.

Where does homebrew install Python? ›

For brewed Python, modules installed with pip or python3 setup.py install will be installed to the $(brew --prefix)/lib/pythonX.Y/site-packages directory (explained above). Executable Python scripts will be in $(brew --prefix)/bin .

What is the default Python for Mac? ›

macOS used to come with Python 2.7 pre-installed between versions 10.8 and 12.3. You are invited to install the most recent version of Python 3 from the Python website (https://www.python.org).

What is the difference between Python and python3 on Mac? ›

On systems that have both versions installed, usually python3 is used to target the python version 3. x.x specifically. python is then used for version2. If your mac only has version3 installed there is no difference by using python to execute your python apps.

How do I know if Python 3 is installed? ›

Checking your current version of Python

To check if it's installed, go to Applications>Utilities and click on Terminal. (You can also press command-spacebar, type terminal, and then press Enter.) If you have Python 3.4 or later, it's fine to start out by using the installed version.

How do I install Python 3.7 on my Mac? ›

Install Python 3 with the Official Installer

First, download an installer package from the Python website. To do that, visit https://www.python.org/downloads/ on your Mac; it detects your operating system automatically and shows a big button for downloading the latest version of Python installer on your Mac.

How do I start running Python? ›

A widely used way to run Python code is through an interactive session. To start a Python interactive session, just open a command-line or terminal and then type in python , or python3 depending on your Python installation, and then hit Enter .

Do I have to download Python to use it? ›

Downloading Python

On many systems Python comes pre-installed, you can try running the python command to start the Python interpreter to check and see if it is already installed.

Which Python version is best for beginners? ›

Although Python 2 has its merits, learning Python 3 is more advantageous, especially for beginning developers. The following are the top reasons why you should learn Python 3. Python 3 improves AI, machine learning, and data science support.

Where is the best place to install Python? ›

By default the Python installer for Windows places its executables in the user's AppData directory, so that it doesn't require administrative permissions. If you're the only user on the system, you might want to place Python in a higher-level directory (e.g. C:\Python3. 7 ) to make it easier to find.

Why is Python installation so complicated? ›

There are very different communities using different versions of python with different libraries, etc. As a result, there are six zillion versions of python (OK, two major versions, 2 & 3, and then multiple release packages for different users/purposes)

How does Python get installed? ›

Type 'Python' in the Windows Search Bar. Right-click on the Python App, and then select “Open file location“ Right-click on the Python shortcut, and then select Properties. Click on “Open File Location“

Which command is used to install Python? ›

The pip command has options for installing, upgrading and deleting packages, and can be run from the Windows command line. By default, pip installs packages located in the Python Package Index (PyPI), but can also install from other indexes.

How to install pip on Mac? ›

Open the Mac Terminal app via the Launchpad. In the Terminal, type python -m ensurepip or python3 -m ensurepip and press Enter. If PIP is missing, ensurepip will install PIP. Follow any additional on-screen instructions to complete this process.

How to install Python without installing? ›

The easiest option is to run Python on Google's Colab servers. This doesn't require any programs to be installed on your local machine. I recommend using Chrome for this.

Which Python is best for Mac? ›

12 BEST Python IDE & Code Editors for Mac & Windows in 2023
  • Comparison Table.
  • #1) PyScripter.
  • #2) PyCharm.
  • #3) Spyder.
  • #4) Pydev.
  • #5) Idle.
  • #6) Wing.
  • #7) Eric Python.
Jun 20, 2023

How to use Python in Mac? ›

Luckily, you can download Python for Mac at any time:
  1. Visit python.org/downloads.
  2. Click Download Python.
  3. Double-click the package file on your Mac.
  4. Proceed through the installation.
May 11, 2021

Which MacBook is best for Python coding? ›

The best laptop for programming we've tested is the Apple MacBook Pro 16 (2021). This premium model feels incredibly well-built and provides a fantastic user experience. Its 16-inch display gives you plenty of room to see more of your codes at once and gets bright enough to combat glare.

Can M1 Macs run Python? ›

Python installed by

Miniforge-arm64, so that python is natively run on M1 Max Chip. (Check from Activity Monitor, Kind of python process is Apple ). Anaconda.: Then python is run via Rosseta. (Check from Activity Monitor, Kind of python process is Intel ).

Does Python need Rosetta? ›

Python has to be installed under Rosetta.

What is the minimum Python version for Mac M1? ›

You can now run Python on the Apple MacBook with M1 Chip

Python 3.9.

How to install Python on Mac 2023? ›

  1. Step 1: Check the Current Version of Python on Your System. ...
  2. Step 2: Visit the Python Website. ...
  3. Step 3: Download the macOS Installer. ...
  4. Step 4: Run the Installer and Follow the Instructions. ...
  5. Step 5: Verify Python and IDLE Are Installed Correctly. ...
  6. Step 6: Verify the Installation with Terminal.
Apr 25, 2023

Is Python automatically installed on Mac? ›

Python comes pre-installed on Mac OS X so it is easy to start using. However, to take advantage of the latest versions of Python, you will need to download and install newer versions alongside the system ones.

Does Python come with Xcode? ›

Xcode provides all tools to create apps (design, develop, and publish) for all Apple's platforms: iOS, iPadOS, tvOS, watchOS, and macOS. In addition, Xcode supports the source code for many popular programming languages, including Swift, Objective-C, Objective-C++, C, C++, Java, Python, and more.

How to install pip in Mac? ›

To install PIP using ensurepip:
  1. Open the Mac Terminal app via the Launchpad.
  2. In the Terminal, type python -m ensurepip or python3 -m ensurepip and press Enter.
  3. If PIP is missing, ensurepip will install PIP. ...
  4. If you want to upgrade PIP, type python -m ensurepip –upgrade or python3 -m ensurepip –upgrade instead.
May 12, 2022

How to install Python 3 on Mac via terminal? ›

Install Python3 on a Mac
  1. Prerequisites for installing Python3 on Mac.
  2. Install Xcode. Xcode is Apple's Integrated Development Environment (IDE). ...
  3. Install Brew. Homebrew installs the stuff you need. ...
  4. Install Python3 with Brew. Enter brew command into terminal. ...
  5. Optional, PATH environment.

How to install Python on Mac Monterey? ›

How to Install Python With the Official Installer
  1. Download the installer package from Python's official website.
  2. Wait for the download to complete. ...
  3. Once the installation is complete, the installer will automatically open Python's installation directory in a new Finder window.
Oct 5, 2022

How do I know if Python is installed on my Mac? ›

To check if Python is installed on your macOS machine, follow these steps: Open the Terminal app by going to the Applications folder or Spotlight search and searching for Terminal. In the command line, type python3. If Python is installed, you should see a message like “Python 3.

How do I install Python 3.8 on Mac terminal? ›

How to install Python on macOS
  1. In a browser, open https://www.python.org/
  2. Click Download to get to the latest version of Python. ...
  3. Click Python 3.8. ...
  4. Double-click to open the installer from downloads. ...
  5. In the installer click Continue. ...
  6. After reading the information presented, click Continue.
Oct 24, 2020

How do I update Python 3.7 to 3.9 on Mac? ›

I suggest use official binaries:
  1. Download version you need from the python.org.
  2. Call the .pkg.
  3. Invoke Update Shell Profile.command script under /Applications/Python\ 3.XX/
  4. After all reboot your terminal.
  5. Check your Python version. The old version and dependencies remain intact.
Feb 2, 2021

How do I install Python 3.9 from terminal? ›

So we will use this repository for installing our python 3.9 version.
  1. Pre Configuration. Open up the terminal with the command Ctrl+Alt+T and then hit the following commands for updating the system. ...
  2. Add Deadsnakes PPA repo in the system. ...
  3. Update the apt-cache and Install Python 3.9. ...
  4. Check Out the New Version.

What is pip command on Mac? ›

PIP is a package management system used to install and manage software packages/libraries written in Python. These files are stored in a large “on-line repository” termed as Python Package Index (PyPI). pip uses PyPI as the default source for packages and their dependencies.

Where pip is installed on Mac? ›

Install and use pip on macOS without sudo / admin access
  1. Run the installation, appending the --user flag; python ~/Downloads/get-pip.py --user . pip will be installed to ~/Library/Python/2.7/bin/pip.
  2. Make sure ~/Library/Python/2.7/bin is in your $PATH . For bash users, edit the PATH= line in ~/. ...
  3. Use pip!

How to install pip in Python using terminal? ›

Step 1: Download the get-pip.py (https://bootstrap.pypa.io/get-pip.py) file and store it in the same directory as python is installed. Step 2: Change the current path of the directory in the command line to the path of the directory where the above file exists. Step 4: Now wait through the installation process. Voila!


Top Articles
Latest Posts
Article information

Author: Nathanael Baumbach

Last Updated: 11/21/2023

Views: 6277

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Nathanael Baumbach

Birthday: 1998-12-02

Address: Apt. 829 751 Glover View, West Orlando, IN 22436

Phone: +901025288581

Job: Internal IT Coordinator

Hobby: Gunsmithing, Motor sports, Flying, Skiing, Hooping, Lego building, Ice skating

Introduction: My name is Nathanael Baumbach, I am a fantastic, nice, victorious, brave, healthy, cute, glorious person who loves writing and wants to share my knowledge and understanding with you.