coin-or / python-mip

Python-MIP: collection of Python tools for the modeling and solution of Mixed-Integer Linear programs
Eclipse Public License 2.0
514 stars 89 forks source link

MIP not compatible with Gurobi 10.X #316

Closed brmanuel closed 1 year ago

brmanuel commented 1 year ago

Describe the bug Trying to use python-mip with Gurobi version 10 installed results in File "/usr/local/lib/python3.9/site-packages/mip/gurobi.py", line 75, in <module> s1 = lib_path.split('"')[-1].split("/")[-1] AttributeError: 'NoneType' object has no attribute 'split'

To Reproduce Fire up a python repl and type import mip.gurobi

Expected behavior The import should work.

Desktop (please complete the following information):

Additional context The problem is the way mip searches for the Gurobi library. It uses the following glob: os.path.join(os.environ["GUROBI_HOME"], "lib/libgurobi[0-9][0-9].*" Which will only match two-digit Gurobi versions, but not version 10.0 which appears as libgurobi100.so

TomManMaz commented 1 year ago

I had the same issue, I substituted in gurobi.py line 65 os.path.join(os.environ["GUROBI_HOME"], "lib/libgurobi[0-9][0-9].*") with os.path.join(os.environ["GUROBI_HOME"], "lib/libgurobi[0-9][0-9][0-9].*")

and now it works for me. Hope it helps

mdeboute commented 1 year ago

Same issue for me @brmanuel but it's look like it does not come from the version of gurobi @TomManMaz since it is gurobi 9.5 in my configuration. Everything works well on my macOS but not Linux. I have the same requirements on both machines, all that differs it's the OS.

[UPDATE]: problem fixed for me, the GUROBI_HOME environment variable was defined in two different places on the linux server... I changed that and now it works!

sebheger commented 1 year ago

i will provide a fix