To launch the Spyder
Python IDE, which is included in the Anaconda distribution, simply type spyder in a terminal window. Gurobi Interactive Shell commands can be typed directly into the Spyder Console window. The console in Spyder is an IPython shell that enables you to execute lines of Python code interactively while using the packages available to the selected Python interpreter (such as gurobipy). Note that a general-purpose Python IDE like Spyder requires you to manually load the Gurobi module by typing from gurobipy import *
(or import gurobipy as gp
) before issuing any Gurobi commands.
Note that to use gurobipy with Spyder you must use an external Python distribution. The standalone installers of Spyder come with a built-in Python environment, but you cannot install additional packages such as gurobipy into this environment. Instead, you must use an external Python distribution with gurobipy and spyder-kernels installed and then link to this Python interpreter via Spyder -> Preferences -> Python interpreter -> Use the following Python interpreter: <path-to-python-with-gurobipy-and-spyder-kernels>.
If you want to run non-Python commands – because it is an IPython shell – you must add a !
before any shell commands, such as !which python
(on Linux and MacOS) or !where python
(on Windows).
Running Gurobi Examples
You can also use Spyder 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 (the green triangle), you should see:
Some Gurobi examples require command-line arguments. Those can be input from the Configure...
item of the Run
menu. For example, to run the sudoku.py example with file sudoku1 as input ...
Comments
0 comments
Article is closed for comments.