You can install Gurobi Optimizer for Python in three different ways:
Please note that you should only install Gurobi into a 64-bit Python installation.
Using pip (gurobipy)
Starting with Gurobi 9.1, you can use pip to install Gurobi into your currently active Python environment:
python -m pip install gurobipy
This command instructs the called Python interpreter to download the gurobipy
extension from the public PyPI server (https://pypi.org) and install it into your Python environment. After the installation succeeds, you should seegurobipy
among the installed packages listed upon typing python -m pip list.
Use this command to install a specific version:
python -m pip install gurobipy==11.0.0
Our pip package includes a limited license that allows you to solve small optimization problems. For more information, please refer to How do I resolve a "Model too large for size-limited Gurobi license" error?
Note: The pip installation method does not provide Gurobi license tools. If you have not yet set up a license on your machine then you will need to use one of the other installation methods or install the license tools package.
Note: Your Python version must be compatible. With Gurobi 11, gurobipy can be used with Python 3.8, 3.9, 3.10, 3.11, and 3.12.
Using conda
If you are using Anaconda Python, you can install Gurobi through Gurobi's conda channel:
conda install -c gurobi gurobi
Use this command to install a specific version:
conda install -c gurobi gurobi=10.0.1
Refer to How do I use conda to install Gurobi in Anaconda? for more information.
Note: Gurobi is not available via conda for all Python versions (full list).
Offline installation
To install Gurobi Optimizer for Python on a machine that doesn't have Internet access, or if there are other reasons for you not to use the pip or conda method, you can download the appropriate wheel file and install it:
- Download the appropriate wheel file for your platform from PyPI.
- Copy it to the machine onto which you want to install Gurobi Optimizer for Python.
- In your shell/terminal, issue the following command, replacing "<wheel-dir>" with the local directory where the wheel files is downloaded:
python -m pip install --find-links <wheel-dir> --no-index gurobipy
Note: Ensure that you have write permissions within this Python installation.
Note: If you are using virtual environments, make sure to activate the virtual environment before installing Gurobi.
Differences between the installation methods
pip | conda | offline installation | |
No Windows admin permissions required | ✅ | ✅ | ✅ |
Can use APIs other than Python | ❌ | ❌ | ❌ |
Easy setup for Docker | ✅ | ✅ | ❌ |
Gurobi license tools (grbgetkey, grbprobe) | ❌ | ✅ | ❌ |
Gurobi shell (gurobi.sh or gurobi.bat) (Deprecated starting version 11.0.2) | ❌ | ❌ | ❌ |
Gurobi command line tools (gurobi_cl, grbcluster, grbtune, grb_ts) | ❌ | ✅ | ❌ |
Can install without Internet access | ❌ | ❌ | ✅ |
(Deprecated) Using setup.py
Note that this option is only available in Gurobi 10 and earlier versions.
Install the full Gurobi Optimizer package:
- Download and install the full Gurobi installation package from our website.
- In your shell/terminal, navigate to the Gurobi installation folder to <installdir>, and issue the following command:
python setup.py install
Note: Ensure that you have write permissions within this Python installation. You may need to install the distutils package before running this command.
Note: If you are using virtual environments, make sure to activate the virtual environment before installing Gurobi.
Further information
- Which Python versions are supported by Gurobi?
- What are some useful Python tools?
- Tutorial: Getting Started with the Gurobi Python API
- Tutorial: Getting Started with the Gurobi Python API using dictionaries
- How do I resolve common installation issues with the Gurobi Python Interface: gurobipy?
- How can I set up a license without installing the full Gurobi package?
- How do I use Gurobi with PyCharm?
Comments
0 comments
Article is closed for comments.