Skip to main content

Gurobi TypeError: __init__() takes exactly 3 positional arguments (4 given)

Answered

Comments

2 comments

  • Official comment
    Simranjit Kaur
    • Gurobi Staff
    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.
  • Riley Clement
    • Gurobi Staff

    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 pyo

    and 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.