Gurobi TypeError: __init__() takes exactly 3 positional arguments (4 given)
AnsweredHi,
I'm coding an optimization AbstractModel, and if I use gurobi as a solver, when running the variable declaration I find the following error message on my Jupyter Notebook. Could someone explain to me why is that?
Best regards,
Juan

-
Official comment
This post is more than two years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum, or try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Juan,
I think this problem is due to you trying to use both Pyomo and gurobipy and getting a namespace clash. It looks like you are trying to define a Pyomo variable, but it is trying to create a gurobipy variable instead and fails due to the method signatures being different.Are you perhaps using
from gurobipy import *
from pyomo import *in your code?
In general it is bad practice to import functionality like this. Instead use
import gurobipy as gp
import pyomo as pyoand then gp.Var and pyo.Var will be different things, and you don't have ambiguity, or one overwriting the other.
- Riley
1
Post is closed for comments.
Comments
2 comments