Installing OR-Tools for Python from Binary on MacOS

Introduction

This guide explains how to install OR-Tools for Python on MacOS.

Although these instructions might also work on other MacOS variants, we have only tested them on machines meeting the following requirements:

  • MacOS 10.14.2 (Mojave) 64-bit (x86_64)

Homebrew

To install the remaining prerequisites, we recommend first installing the "missing package manager for macOS" otherwise known as Homebrew. To do so, open a terminal window and enter:

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

To verify that you’ve successfully installed brew:

brew --version

You should see:

Homebrew 1.6.9-8-g25542d7
Homebrew/homebrew-core (git revision 0e0c84; last commit 2018-06-20)

Python

You must have Python 2 or Python 3.7+ installed. We recommend Python 3.

Python 3

To install Python 3.7+, open a terminal window and enter:

brew install python
python3 -m pip install -U --user wheel six

Then verify your installation:

python3 --version
python3 -c "import platform; print(platform.architecture()[0])"
python3 -m pip --version

Python 2

To install Python 2.7, open a terminal window and enter:

brew install python@2
python2 -m pip install -U --user wheel six

Then verify your installation:

python2 --version
python2 -c "import platform; print(platform.architecture()[0])"
python2 -m pip --version

Installing OR-Tools

Assuming the prerequisite software is installed on your MacOS, take the following steps:

python -m pip install -U --user ortools

Or, to install it system wide:

sudo python -m pip install -U ortools

Uninstalling OR-Tools

To uninstall OR-Tools, issue the following commands:

python -m pip uninstall ortools

Validate your installation

To test your Python installations, open a terminal window. Then enter the following command:

python -c "from ortools.linear_solver import pywraplp"

If it runs successfully, you are ready to get started with OR-Tools.

Send feedback about...