Getting "MethodError: no method matching Model()" when initializing models on JuMP

I’m using JuMP and had several models that were running fine. Now, whenever I try to initialize a model (for example Model(Gurobi.Optimizer)), I get the error:

MethodError: no method matching Model(::Type{Gurobi.Optimizer})
Closest candidates are:
  Model(::Any, !Matched::Symbol, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Int64, !Matched::Array{String,1}, !Matched::Array{String,1}, !Matched::Array{Float64,1}, !Matched::Array{Float64,1}, !Matched::Array{Symbol,1}, !Matched::Array{T,1} where T, !Matched::Array{Tuple{Symbol,Any},1}, !Matched::Any, !Matched::Any, !Matched::Array{Float64,1}, !Matched::Array{Float64,1}, !Matched::Array{Float64,1}, !Matched::Array{Float64,1}, !Matched::Array{Array{Int64,1},1}, !Matched::Array{Array{Tuple{Int64,Int64},1},1}, !Matched::Any, !Matched::MathProgBase.SolverInterface.AbstractMathProgSolver, !Matched::Bool, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Array{T,1} where T, !Matched::JuMP.IndexedVector{Float64}, !Matched::Any, !Matched::Bool, !Matched::Dict{Symbol,Any}, !Matched::IdDict, !Matched::Int64, !Matched::Int64, !Matched::Dict{Symbol,Any}) at /Users/Hassan/.julia/packages/JuMP/I7whV/src/JuMP.jl:87
  Model(::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any) at /Users/Hassan/.julia/packages/JuMP/I7whV/src/JuMP.jl:87
  Model(; solver, simplify_nonlinear_expressions) at /Users/Hassan/.julia/packages/JuMP/I7whV/src/JuMP.jl:168
top-level scope at haha.jl:15

Note that I had initialized both JuMP & Gurobi (e.g. using JuMP, Ipopt, Gurobi, LinearAlgebra) prior to creating the model. I have tried restarting my laptop and updating the packages I’m using, but the error is still there.

Any idea what went wrong? It was working fine… until it wasn’t.

1 Like

Looks like you’re using an old version of JuMP.

Check the output of ] status. But either run ] up, or try ] add JuMP@0.21 to see why it downgraded. You probably installed an outdated package.

If it doesn’t work, post the output of all these commands and we can see what the problem is.

Thank you for your reply. I tried adding ] add JuMP@ and got the following error code:

ERROR: Unsatisfiable requirements detected for package Pajarito [2f354839]:
 Pajarito [2f354839] log:
 ├─possible versions are: [0.6.1, 0.7.0] or uninstalled
 ├─restricted to versions * by an explicit requirement, leaving only versions [0.6.1, 0.7.0]
 └─restricted by compatibility requirements with JuMP [4076af6c] to versions: uninstalled — no versions left
   └─JuMP [4076af6c] log:
     ├─possible versions are: [0.18.3-0.18.6, 0.19.0-0.19.2, 0.20.0-0.20.1, 0.21.0-0.21.3] or uninstalled
     └─restricted to versions 0.21 by an explicit requirement, leaving only versions 0.21.0-0.21.3```

I assume something happened when i tried installing Pajarito.jl? Any idea how to uninstall it so thhat it doesn’t interfere with JuMP?

Thanks again.

] rm Pajarito.

Thank you so much @odow. JuMP is up and running again.

For future reference, is there any resource/ way to figure out whether installing a package will cause a similar deprecation?

is there any resource/ way to figure out whether installing a package will cause a similar deprecation?

Not really. We need something like this: Optionally warn if `update` cannot install latest version of a package · Issue #1655 · JuliaLang/Pkg.jl · GitHub

See also: Package versions, how to make it less confusing?

2 Likes

I had a similar issue

 add JuMP@0.21
  Resolving package versions...
ERROR: Unsatisfiable requirements detected for package JuMP [4076af6c]:
 JuMP [4076af6c] log:
 ├─possible versions are: [0.18.3-0.18.6, 0.19.0-0.19.2, 0.20.0-0.20.1, 0.21.0-0.21.5] or uninstalled
 ├─restricted to versions 0.21 by an explicit requirement, leaving only versions 0.21.0-0.21.5
 └─restricted by compatibility requirements with ConditionalJuMP [ae04f764] to versions: 0.18.3-0.18.6 — no versions left
   └─ConditionalJuMP [ae04f764] log:
     ├─possible versions are: 0.1.0 or uninstalled
     └─restricted to versions * by an explicit requirement, leaving only versions 0.1.0

I solved this by ] rm ConditionalJuMP and then add JuMP@0.21.0

I hope this be useful

2 Likes