216

I was watching this, and, as you can see, the first command I am told to put in is:

sudo apt-get install python-setuptools

When I do this, it outputs:

sudo: apt-get: command not found

I have no idea why this is the case.

How can I resolve this so I am following the tutorial correctly?

0

6 Answers 6

299

Mac OS X doesn't have apt-get. There is a package manager called Homebrew that is used instead.

This command would be:

brew install python

Use Homebrew to install packages that you would otherwise use apt-get for.

The page I linked to has an up-to-date way of installing homebrew, but at present, you can install Homebrew as follows:

Type the following in your Mac OS X terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

After that, usage of Homebrew is brew install <package>.

One of the prerequisites for Homebrew are the XCode command line tools.

  1. Install XCode from the App Store.
  2. Follow the directions in this Stack Overflow answer to install the XCode Command Line Tools.

Background

A package manager (like apt-get or brew) just gives your system an easy and automated way to install packages or libraries. Different systems use different programs. apt and its derivatives are used on Debian based linux systems. Red Hat-ish Linux systems use rpm (or at least they did many, many, years ago). yum is also a package manager for RedHat based systems.

Alpine based systems use apk.

Warning

As of 25 April 2016, homebrew opts the user in to sending analytics by default. This can be opted out of in two ways:

Setting an environment variable:

  1. Open your favorite environment variable editor.
  2. Set the following: HOMEBREW_NO_ANALYTICS=1 in whereever you keep your environment variables (typically something like ~/.bash_profile)
  3. Close the file, and either restart the terminal or source ~/.bash_profile.

Running the following command:

brew analytics off

the analytics status can then be checked with the command:

brew analytics
6
  • 1
    @Panique install homebrew or if you have done it, reopen your terminal.
    – Godisemo
    Commented Feb 13, 2014 at 11:57
  • 4
    it's worth noting that Mac OS X is a unix-based OS (Unix -> BSD -> NeXTSTEP -> Mac OS X) :)
    – refaelio
    Commented Apr 28, 2015 at 9:26
  • In High Sierra, I still get sudo: apt-get: command not found after installing Homebrew. :(
    – jimiayler
    Commented Dec 6, 2018 at 15:57
  • 2
    @jimiayler apt-get will never be available via brew. You should use brew install <x> for whatever you would have written sudo apt-get install <x>. Commented Dec 7, 2018 at 18:03
  • 1
    @refaelio It's not just unix-based, it's Unix / POSIX certified, even Linux isn't so much of a unix as macOS
    – Misty
    Commented Jun 10, 2020 at 16:51
7

As Homebrew is my favorite for macOS although it is possible to have apt-get on macOS using Fink.

3

MacPorts is another package manager for OS X:.

Installation instructions are at The MacPorts Project -- Download & Installation after which one issues sudo port install pythonXX, where XX is 27 or 35.

3

apt-get command is only available on Debian or Debian-based Linux distributions (such as Ubuntu, Linux Mint, Kali). It is not accessible on macOS. Alternatively, you can use package managers like Homebrew, MacPorts, and Nix. You can find equivalent commands for each as follows

brew install package_name

sudo port install package_name

nix-env -i package_name

Before installing above package managers, you need to install XCode first.

2

Conda can also be used as package manager. It can be installed from Anaconda.

Alternatively, a free minimal installer is Miniconda.

-4

Alternatively You can use the brew or curl command for installing things, wherever apt-get is mentioned with a URL...

For example,

curl -O http://www.magentocommerce.com/downloads/assets/1.8.1.0/magento-1.8.1.0.tar.gz

Not the answer you're looking for? Browse other questions tagged or ask your own question.