4

I tried to install the gurobi package on python 3 but it didn't work. The command that i am using on my macbook is: pip install gurobipy, but it doesn't work, it shows me this:

ERROR: Could not find a version that satisfies the requirement gurobipy (from versions: none) ERROR: No matching distribution found for gurobipy`

Robert
  • 575
  • 3
  • 12
M.HANHASSE
  • 129
  • 1
  • 6
  • Just got the same error in Python 3.11, as there isn't yet a compatible `gurobipy` version. – AlexM Oct 27 '22 at 04:13

4 Answers4

5

On macOS gurobipy is automatically installed in the system's python installation. If you need to install it within another python installation or virtual environment, too, then you need to install gurobipy like described at the end of this section in the quickstart guide. It boils down to going to the installation directory of Gurobi, and running an installer script:

(venv) bash-3.2$ cd /Library/gurobi811/mac64/
(venv) bash-3.2$ python setup.py install
Robert
  • 575
  • 3
  • 12
  • i am trying to install it on my pycharm and everytime i want to install it there it shows me that error message – M.HANHASSE May 19 '19 at 08:33
  • You cannot use pip to install gurobipy, please run the `setup.py` script as indicated in my answer from withing a Pycharm terminal. – Robert May 19 '19 at 08:57
4

fyi for pip installs:

  1. use the following command for python 3.0+

python -m pip install -i https://pypi.gurobi.com gurobipy

  1. obtain the relevant license and activate using grbgetkey (have to download gurobi install files from website to access grbgetkey as that's not installed using pip

  2. copy the gurobi.lic file wherever you initially installed it to the following directory: [your python dir]/site-packages/gurobipy/.libs **note there is an existing restricted install license in the directory, simply replace it.

Restart the kernel for python and the new license will be activated. No idea why Gurobi hasn't already published this info on their website for python pip installations.

mathcomp guy
  • 139
  • 9
1

Given that @Robert's answer focused on macOS, the solution below will work for Windows users. The installation process is as follows, per the Gurobi Documentation:

  • Step 1: Download and Install Anaconda -- see get anaconda for more details. Obviously, you can skip this step if you have Anaconda already installed (which is not uncommon if you are already a Python user).
  • Step 2: Install Gurobi into Anaconda, which can be done as follows:

The next step is to install the Gurobi package into Anaconda. You do this by first adding the Gurobi channel to your Anaconda channels and then installing the gurobi package from this channel.

From a terminal window issue the following command to add the Gurobi channel to your default search list:

conda config --add channels http://conda.anaconda.org/gurobi

Now issue the following command to install the Gurobi package:

conda install gurobi
  • Step 3: Install a Gurobi License The third step is to install a Gurobi license (if you haven't already done so).
0

In this link it is explainded the three ways of installing it. As the pip way is not working, it is possible to use the other ones. The anaconda way it is already covered in this Stackoverflow question. The third way it is also covered in this quiestion by Robert but he only says that this is for MacOs users. Window and Linux users do also get gurobipy installed after installing the optimizer