AI-generated Key Takeaways
-
This guide provides instructions for installing and running OR-Tools, a Python library for optimization, on a Windows 64-bit system with specified prerequisites.
-
Before installing OR-Tools, ensure you have the Microsoft Visual C++ Redistributable for Visual Studio 2022 (x64 version) and a compatible 64-bit Python version (3.8.x, 3.9.x, 3.10.x, or 3.11.x) with pip 9.01 or higher.
-
OR-Tools can be installed using pip with the command
python3 -m pip install -U --user ortools(user-specific) orsudo python3 -m pip install -U ortools(system-wide). -
You can run a basic OR-Tools example by downloading the
python_or-toolsrepository, navigating to theexamplesdirectory, and executingpython3 basic_example.py.
Introduction
This guide gets you started with OR-Tools in Python with a simple working example.
Although these instructions might also work on other Windows variants, we have only tested them on machines meeting the following requirements:
Windows 10 64-bit (x86_64) with:
- Microsoft Visual Studio Enterprise 2022
- Microsoft Visual Studio Community 2022 Preview 2 or above
Prerequisites
The following sections describe the prerequisites for installing OR-Tools.
Microsoft Visual C++ Redistributable
You must have the Microsoft Visual C++ Redistributable for Visual Studio 2022 (select the x64 version) installed on your computer, since OR-Tools library for Python is a wrapper for the C++ native library.
Python
You must have one of the following versions of Python installed:
Then verify that you have pip 9.01 or higher available in your PATH:
python --versionpython -c "import platform; print(platform.architecture()[0])"python -m pip --version
Installing OR-Tools
Assuming the prerequisite software is installed on your Windows, take the following steps:
python3 -m pip install -U --user ortoolsOr, to install it system wide:
sudo python3 -m pip install -U ortoolsUninstalling OR-Tools
To uninstall OR-Tools, issue the following commands:
python3 -m pip uninstall ortoolsGet the Python example code
The example code is located in the python_or-tools repository.
Download the repository as a zip file and extract it, or clone the repository:
git clone -b v9.12 --depth 1 https://github.com/or-tools/python_or-toolsChange to the examples directory:
cd python_or-tools
Run the example
From the python_or-tools directory:
Run the binary using:
python3 basic_example.pyCongratulations! You've just run an application with OR-Tools, you are ready to get started with OR-Tools.