Try our new documentation site (beta).
Installing a Python IDE
While command-line tools are likely to be familiar to Linux users and to most Mac users, we realize that the command line can be quite foreign to a Windows user. This section guides you through the steps involved in installing PyScripter, a free and widely-used Python Integrated Development Environment (IDE) for Windows. PyScripter makes it easier for Windows users to use the Gurobi Interactive Shell, and to develop and debug programs that use the Gurobi Python interface.
If you are using Gurobi on a Linux or Mac platform, or if you would like to consider other IDE options on Windows, a number of other free Python IDEs are available. Popular choices include Eric, iep, and PyDev. We won't be covering the details of installing these other options for use with Gurobi, but the PyScripter instructions that follow should provide a good outline for the steps involved. We've found that PyScripter provides a nice balance between power and complexity, but we realize that people may look for different things in their IDEs.
Step 1: Install Gurobi
The first step in using Gurobi from Pyscripter is to install Gurobi on your machine and install a Gurobi license (if you haven't already done so).
Step 2: Install Python
The next step is to install a stand-alone Python interpreter. Be sure to install a version that is compatible with the version of Gurobi you installed. We recommend Python 2.7, but Python 3.2 is also an option:
Choose the Windows X86-64 Installer
if you installed the 64-bit
version of Gurobi, or the Windows Installer
if you installed the
32-bit version of Gurobi.
Note that Python gives you the option of choosing an install directory, but PyScripter will only be able to find it if you stick with the default.
Step 3: Install Gurobi into Python
The third step is to run a simple program that installs the Gurobi
module into Python. Simply double-click on pysetup
in the
bin
folder of your Gurobi installation
(c:\gurobi560\win64\bin
for a default installation of the
64-bit Windows version). The program will prompt you for the location
of your Python installation. When the program is finished, you should
see output that looks like the following:
Step 4: Install PyScripter
The final step is to install PyScripter:
Again, choose the x64-Setup
version if you installed the 64-bit
version of Gurobi, or the Setup
version if you installed the
32-bit version of Gurobi.
One installation of PyScripter can work with multiple versions of
Python. You will need to launch the one that corresponds to the
Python version you installed (we used PyScripter for Python 2.7
in this example):
Using PyScripter
Gurobi Interactive Shell commands can be typed directly into the
Python Interpreter
window of PyScripter:
Unfortunately, a general-purpose Python IDE like PyScripter requires
one extra step that isn't required when you launch the Gurobi shell
from the Gurobi icon or by using the gurobi.sh
command: you
must type from gurobipy import *
before issuing any Gurobi
commands. Unlike our icon or our gurobi.sh
command, the IDE
won't load the Gurobi module automatically, so you must do it
manually.
You can also use PyScripter to run any of the Gurobi examples. For
example, if you use Open
under the File
menu to open
Gurobi example mip1.py
, and then click on the Run
icon,
you should see:
Some Gurobi examples require command-line arguments. Those can
be input from the Command Line Parameters... item of
the Run
menu. For example, to run the sudoku.py
example with file sudoku1
as input...
A few Gurobi examples require additional Python modules. For example,
our diet4
example uses the Python
xlrd
module to
extract data from an Excel spreadsheet. You can find missing Python
modules at the Python Package Index (PyPI)
site. The Python interpreter that we
include with our distribution includes all the modules used by our
examples. When you install your own Python interpreter, you may have
to install some modules yourself from this site.