Installing OR-Tools for Python from Binary on Linux

Introduction

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

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

  • Ubuntu 19.04/18.04/16.04 64-bit (x86_64)
  • Debian 9.4 (stretch) 64-bit (x86_64)
  • Centos 7 64-bit (x86_64)

Python

You must have either Python 2.7 or Python 3.5+ installed. We recommend Python 3.

Python 3

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

Centos 7

yum -y install centos-release-scl
yum -y install rh-python36 rh-python36-python-wheel rh-python36-python-six
scl enable rh-python36 bash

Debian 9

sudo apt-get -y install python3-dev python3-wheel python3-setuptools python3-six

Ubuntu 19.04

sudo apt-get -y install python3-dev python3-wheel python3-setuptools python3-six

Ubuntu 18.04

sudo apt-get -y install python3-dev python3-wheel python3-setuptools python3-six

Ubuntu 16.04

sudo apt-get -y install python3-dev python3-wheel python3-setuptools python3-six

You can check your Python 3 installation using:

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:

Centos 7

yum -y install centos-release-scl
yum -y install python27 python27-python-six
scl enable python27 bash

Debian 9

sudo apt-get -y install python-dev python-wheel python-setuptools python-six

Ubuntu 19.04

sudo apt-get -y install python-dev python-wheel python-setuptools python-six

Ubuntu 18.04

sudo apt-get -y install python-dev python-wheel python-setuptools python-six

Ubuntu 16.04

sudo apt-get -y install python-dev python-wheel python-setuptools python-six

You can check your Python 2 installation using:

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 Linux, 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.