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==10.0.1
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 10, gurobipy can be used with Python 3.7, 3.8, 3.9, 3.10 and 3.11.
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
Note: Gurobi is not available via conda for all Python versions (full list).
Using setup.py
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.
Differences between the installation methods
pip | conda | full installer | |
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) | ❌ | ❌ | ✅ |
Gurobi command line tools (gurobi_cl, grbcluster, grbtune, grb_ts) | ❌ | ✅ | ✅ |
Offline installation | ❌ | ❌ | ✅ |
Further information
- Which Python versions are supported by Gurobi?
- 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 update my Gurobi installation to a newer version?
- How do I use Gurobi with PyCharm?
- What are some useful Python tools?
Comments
4 comments
I do not understand how to access setup.py as my Gurobi Optimizer package is a .pkg file? I first used pip to install Gurobi, but my model was too large. Now I am trying to use the full installer without size limitations.
A .pkg file is an installer file for MacOS. You start the Gurobi package installation by double-clicking on the file. Once the package is installed, you can find setup.py in your \(\texttt{<installdir>}\).
How can I find my <installdir>? The .pkg file is dowloaded to "Downloads" by default. After I run the installation process using the .pkg file, there are no files to be found in the "Downloads" folder.
Hi Marthe,
For a default Mac install, Gurobi 10.0.1 will be installed in the directory \(\texttt{/Library/gurobi1001}\). The \(\texttt{<installdir>}\) is \(\texttt{/Library/gurobi1001/macos_universal2}\).
Cheers,
Matthias
Please sign in to leave a comment.