This guide explains how to install OR-Tools from source, with support for Python, on MacOS.
Unless you plan to modify the source code or use a third-party solver with OR-Tools, we recommend the binary installation.
Although these instructions might also work on other MacOS variants, we have only tested them on machines meeting the following requirements:
- MacOS 12.5 (Monterey) Intel 64-bit (x86_64)
- MacOS 12.5 (Monterey) M1 (arm64)
The following sections describe the prerequisites for installing OR-Tools.
Xcode Command Line Tools
You must install the Xcode Command Line Tools. To do so, open the
Terminal, found in
/Applications/Utilities/, and enter:
Click “Install” to download and install Xcode Command Line Tools. You don’t need to "Get Xcode" from the App Store. If you have a slow Internet connection, it may take many minutes.
Verify that you’ve successfully installed Xcode Command Line Tools:
You should see:
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:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
To verify that you’ve successfully installed brew:
You should see:
Homebrew 1.6.9-8-g25542d7 Homebrew/homebrew-core (git revision 0e0c84; last commit 2018-06-20)
To install C++ tools, open a terminal window and enter:
brew install cmake wget pkg-config
To install SWIG tool, open a terminal window and enter:
brew install swig
You must have Python 3.6+ installed.
To install Python 3.6+, open a terminal window and enter:
brew install python
python3 -m pip install -U --user wheel six
Then verify your installation:
python3 -c "import platform; print(platform.architecture())"
python3 -m pip --version
Download the source code
There are two distinct branches of the OR-Tools source code on
stable branch has been thoroughly tested and should work flawlessly on all
main branch is where the latest updates and
improvements have been applied; it's more current, but less stable.
Download the stable source code
You can get the stable source code for OR-Tools in either of the following ways:
stablebranch by entering:
git clone https://github.com/google/or-tools
Download the latest release in a compressed file, by clicking the
Clone or downloadbutton in GitHub.
Download the main source code
To retrieve the source code from the
main branch, enter:
git clone -b main https://github.com/google/or-tools
Download previous releases
You can get the source code for previous releases in either of the following ways:
- Download a previous release from the GitHub release page.
Assuming you have already created a local repository (by
git clone), you can check out a specific release using a Git tag. For example, to work with the v9.4 release instead of the
mainbranch, enter the following commands in your local repo:
git fetch --all --tags --prune
git checkout tags/v9.4 -v v9.4
Build third parties
Before building OR-Tools, you'll need to build the required third party software.
Open a terminal and navigate to the directory where you extracted the files. Then enter:
Since v7.8, SCIP is now integrated so you won't have to install it manually.
Gurobi is now pre-integrated. When needed, at runtime, OR-Tools will search for
the Gurobi shared library in the default install path of the Gurobi installers
on MAC OS X and Windows, or by using the
GUROBI_HOME environment variable.
Using an optional third-party MIP solver
You can also use OR-Tools with any of the following optional third-party MIP solvers whose support is disabled by default:
To configure OR-Tools to use one of these solvers, do the following steps:
- Install the optional solver following the vendor instruction.
Makefile.localand add the path to the directory where you have installed the solver. For example, for CPLEX you would add this:
Build the source code
To build the source code, open a terminal and navigate to the directory where you extracted the files. Then enter the following command to compile OR-Tools:
Test the source code
You can check that everything is running correctly by entering:
This runs a selection of examples for OR-Tools. If all the examples run successfully, you are ready to get started with OR-Tools.
Cleaning the build files
If you need to re-install OR-Tools, the command:
will remove all compiled dependencies and
This can be useful for resetting to a clean state.
Then re-enter the commands:
Installing OR-Tools on your operating system
You can install OR-Tools for Python on your operating system by entering