Cookie Settings
Customize Consent Preferences
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Always Active

Necessary cookies are required to enable the basic features of this site, such as providing secure log-in or adjusting your consent preferences. These cookies do not store any personally identifiable data.

Functional cookies help perform certain functionalities like sharing the content of the website on social media platforms, collecting feedback, and other third-party features.

Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics such as the number of visitors, bounce rate, traffic source, etc.

Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.

No cookies to display.

Advertisement cookies are used to provide visitors with customized advertisements based on the pages you visited previously and to analyze the effectiveness of the ad campaigns.

Other cookies are those that are being identified and have not been classified into any category as yet.

Rich Python Modeling Environment

Leverage the Power of Python


With our Python API, you get the ease of a modeling language with the power of a programming language.

 

Our Python API includes higher-level modeling constructs that make it easier to build optimization models. Choose from Anaconda Python distributions with pre-built libraries to support application development, Spyder for graphical development, and Jupyter for notebook-style development.

  • Python interactive interface for powerful prototyping and quick testing
  • Language extensions for easier coding of a model
  • Documented best practices to get you started quickly
  • Pre-built Python libraries support full application development
  • Python Matrix API for matrix-oriented modeling using NumPy or SciPy matrices

Together, Gurobi’s Python API and distributions, like Anaconda, give you the ease of a modeling language with the power of a programming language. Additionally, we provide an interactive interface that uses Python for quick testing.

To use Gurobi and Anaconda:

Building an Optimization Model: Exploring Your Options

When building an optimization model, you must choose from among two alternatives: Using Gurobi with a proprietary modeling language such as AMPL or GAMS, or using Gurobi with a full programming language such as C, C++, C#, Java, Python, VB, MATLAB or R.

Using a modeling language can be an attractive choice, especially for non-programmers, given the perceived ease with which a model can be formulated. Using a programming language can be a much more powerful and flexible choice if you are interested in formulating a model and then deploying that model and/or integrating it into an application for others to use.

This perceived trade-off led us to wonder, why should someone have to choose between easy or powerful? Is there a way to combine the ease of the modeling language with the power and flexibility of a programming language, without requiring significant programming skills on the part of the modeler?

Introducing the Gurobi Python Environment

The Gurobi Python Environment combines the benefits of a modeling language with the strengths of a programming language. By embedding our set of high-level optimization modeling constructs in the very popular Python programming language, we’ve eliminated the need to choose between working in just a modeling language or just a programming language.

The Gurobi Python environment allows you to tap into the vast ecosystem of Python, a mature, full-featured, and easy-to-use language. With Python, you can take advantage of numerous available pre-written and tested packages (over 200,000 at last count) that can save you significant development time when creating new capabilities for your program.

And based on our experience, since Python is a very readable and easy programming language to get started with, we think you’ll be most productive in the Gurobi Python environment—even if you are already familiar with another programming language. By using Python, we’ve created an environment that is:

  • Flexible and powerful – Use it just for prototyping, or to create full-featured optimization applications.
  • Easy to use – Create simple models, requiring a very basic understanding of the language. Create more complex models that are still concise, efficient, and easy to express with just a bit more knowledge.
  • Robust – Take advantage of Python’s full range of pre-built packages to support full application development, including exceptional data access capabilities. These capabilities are in part the result of a very large and rapidly growing user community.

 

Build Better Optimization Applications in Less Time

To help you get started quickly, the Gurobi distribution includes a Python interpreter and a basic set of Python packages. While these are sufficient for building and running simple optimization models, they provide just a glimpse of the wealth of tools and packages that are available for Python.

You can further enhance your development experience by downloading a full Python environment and installing our gurobipy interface.

We recommend Anaconda, a free and widely used Python distribution that includes an Integrated Development Environment (Spyder), a notebook-style interface (Jupyter), and a broad set of 270 of the most useful Python packages. These tools can significantly increase the interactivity and productivity of your Python model and application-building experience.

We provide tools to make it easy to use Gurobi from within your Python environment:

  • For Anaconda users, we provide an Anaconda package (see links above) that makes it easy to install our gurobipy interface.
  • If you are using a different distribution, we also provide a PyPI package that installs gurobipy using the widely available pip tool.
    Just say ‘python -m pip install gurobipy’.

 

Here are just a few examples of the types of things you can do from within a Python environment:

  • Extract data stored in a database
  • Build a machine learning model to identify patterns in your data
  • Build a GUI to capture user input and display results
  • Capture and explore your results in a Jupyter notebook

There are over 200,000 Python packages available, which makes Python a lot more than just a programming language.

 

Try It Now

To get started using the Gurobi Python Environment:

  • Install a Python distribution (Anaconda or another).
  • Install our gurobipy package (conda or pip) within that Python environment.

Consult the Python section of our Knowledge Base to learn more.

 

Guidance for Your Journey

30 Day Free Trial for Commercial Users

Start solving your most complex challenges, with the world's fastest, most feature-rich solver.

Always Free for Academics

We make it easy for students, faculty, and researchers to work with mathematical optimization.