Python and Pip Installation Instructions for Linux and Mac OS

share link

by kandikits dot icon Updated: Jul 31, 2023

technology logo
technology logo

Guide Kit Guide Kit  

In this article, you can learn the step-by-step instructions on how to install Python and Pip for Linux and Mac OS.


This document describes how to install Python 3.9 version and pip on Linux and Mac OS. The version of python can be replaced in the code as needed. Please follow installation instructions for Python and then pip.


Python Installation:

Linux Distros:

If you are using Ubuntu 16.10 or newer, then you can easily install Python 3.9 with the following commands:

sudo apt-get update
sudo apt-get install python3.9

If you’re using another version of Ubuntu (e.g. the latest LTS release), then you can install Python 3.9 with the following commands:

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.9

If you are using other Linux distribution, chances are you already have Python 3 pre-installed as well. If not, use your distribution’s package manager. For example on Fedora, you would use dnf:

sudo dnf install python3.9

Mac OS:

Install Python in the macOS terminal using the Homebrew package manager. If you do not have Homebrew, install it by typing the following script in the terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

install Python 3.9 with the command:

brew install python@3.9

Pip Installation:

Linux Distros:

Once Python 3.9 is installed, ou can install pip for python 3.9 for Linux distros the following way:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.9 get-pip.py

If you get an error when running the above command, try running

sudo apt-get install python3.9-distutils

and then run the python3.9 get-pip.py command

You can verify the installation of pip by running:

pip3 --version

Mac OS:

Brew installation installs Pip with Python. You can verify the installation of pip by running:

pip3 --version