Building and running the examples

Python is an interpreted language, so no explicit compilation step is required to run the examples. For Windows platforms, you can simply type the following in the Gurobi Python example directory (<installdir>/examples/python):

  gurobi.bat mip1.py
For Linux or Mac OS platforms, type:
  gurobi.sh mip1.py

If you are a Python user, and wish to use Gurobi from within your own Python environment, you can install the gurobipy module directly into your environment. The steps for doing this depend on your platform. On Windows, you can double-click on the pysetup program in the Gurobi <installdir>/bin directory. This program will prompt you for the location of your Python installation; it handles all of the details of the installation. On Linux or Mac OS, you will need to open a terminal window, change your current directory to the Gurobi <installdir> (the directory that contains the file setup.py), and issue the following command:

  python setup.py install
Unless you are using your own private Python installation, you will need to run this command as super-user. Once gurobipy is successfully installed, you can type python mip1.py (more generally, you can type from gurobipy import * in your Python environment).

Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.

Search