Combine Gurobi and iPython

I recently undertook a Python workshop where we were taught the potential and flexibility of this language, especially when using an extension as iPython with Pylab. For those who are not familiar with Python, it is an open source programming language that can be either used as a script language or object oriented language. Many libraries have been developed, giving functionalities close to Matlab.

Knowing that the Gurobi opimizer console is based on Python, I found that it was possible to integrate the Gurobi library in any Python environment (with version higher to 2.5).

You first need to install a distribution of Python (academics can for instance install for free the Enthought distribution), then run the “” script in the Gurobi install folder (with the command python

You can then open an iPython console by typing “ipython -pylab“, and import the Gurobi library with “import gurobipy“. All functions from the Guroby library can be accessed with the “gurobipy.” prefix. Examples of python scripts to create Gurobi models can be found in the “examples\python” subdirectory in the Gurobi installation directory.

If you find the creation of a model from the Python API difficult, you may want to check how to use the Gusek IDE to write your model.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s