Gurobi Python Interface

Gurobi released the latest 7.0 version optimizer in Oct. 2016, and Python modeling enhancements is one of the new features. Because of an ongoing paper, an integer programming model is required. Since I’ve been self-taught to Python for months, I attempt to renew my Gurobi license and study how it works with Python.

Basically, you can just download the documentation of Gurobi and find whatever you what to know. Here are links:

This note is only for those super beginners who just want to solve the optimization problem using Gurobi Python Interface but didn’t know how to complete the setting for making it happens.

Python is a powerful language and FREE. However, the installation for beginners may be a little bit confusing. Anaconda is a modern open source platform powered by Python. This Python distribution includes almost the most popular tools for Python programmers such as Spyder and Jupyter, of course, it also consists of those must-have modules/packages so that you don’t have to worry about it. Go picking up the version of Anaconda fits your requirement (Python2/3, Win32/x64) and install.

After that, From an Anaconda terminal issue the following command to add the Gurobi channel to your default search list:

conda config –add channels

Then issue the following command to install the Gurobi:

conda install gurobi

Your Gurobi is almost ready to go, just remember to install the Gurobi license. There are some examples can verify your Gurobi+Python is workable or not.

For Windows, type the following in the Gurobi Python example directory (<installdir>/examples/python):


For Linux or Mac OS, type:


By the way, if you’ve already installed Python, you have to install the gurobipy module  directly into your environment. For Windows, go looking for the pysetup program in the Gurobi <installdir>/bin directory. This program will prompt you for the location of your Python installation and handle all of the remain jobs. Similar file in the Gurobi <installdir> is for Linux and Mac OS; issue the following command to install:

python install

Once gurobipy is successfully installed, change to the examples directory and try python, the result should be like follows:

Enjoy !






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 )

Google+ photo

You are commenting using your Google+ 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 )

Connecting to %s