Installing and switching to Gurobi (COBRApy)

624 views
Skip to first unread message

Stephen Chapman

unread,
Oct 10, 2017, 6:51:07 AM10/10/17
to Gurobi Optimization

Hi all,  

I want to re-create some previous FBA results, but this time I'm using Python and want to choose the same solver, which is the GUROBI solver.  I'm really new to python and struggling to switch solvers from GLPK .

When I type:

>>> m.solver
<optlang.glpk_interface.Model object at 0x114e81c50>


>>> from optlang import gurobi_interface

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

  File "/Users/stephenchapman/anaconda/lib/python3.6/site-packages/optlang/gurobi_interface.py", line 36, in <module>

    import gurobipy

ModuleNotFoundError: No module named 'gurobipy'



Now I have downloaded GUROBI and obtained my license, so any help would be greatly appreciated.


Cheers!



Daniel Espinoza

unread,
Oct 11, 2017, 7:30:22 AM10/11/17
to Gurobi Optimization
Hi Stephen,

From the message, it looks like you have not installed gurobi for python. I would recommend following these directions:


Also, if you are switching, I would recommend taking a look at Gurobi's python interface, which is described here


and code examples here


Best,
Daniel

Amarjeet Kumar

unread,
Mar 30, 2018, 9:06:35 AM3/30/18
to Gurobi Optimization
Hello Daniel,

I am able to import gurobipy, optlang in python and also able to import gurobi_interface form optlang
but while performing Flux balance analysis using Cobrapy when I read my model the model does not have any attribute named solver.

Pleas suggest the suitable solution to this problem
Thanks

Daniel Espinoza

unread,
Apr 3, 2018, 8:49:04 AM4/3/18
to Gurobi Optimization
Hi Amarjeet,

Can you provide a log showing the error? Also, I don't understand what you mean by a model not having a solver attribute... gurobi models don't have such an attribute... could you share a minimal code exhibiting the issue?

Best,
Daniel

Amarjeet Kumar

unread,
Apr 3, 2018, 11:18:13 AM4/3/18
to gur...@googlegroups.com
Hi Daniel,

Thanks for the giving me some time. There was a problem with the COBRApy version. I was using very old version of this software. I upgraded it and it was solved.

Thanks for the help.

Thank you

--

---
You received this message because you are subscribed to the Google Groups "Gurobi Optimization" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gurobi+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Best Regards

Amarjeet Kumar
Ph.D. Student
SC&IS, JNU

Daniel Espinoza

unread,
Apr 5, 2018, 6:02:24 AM4/5/18
to Gurobi Optimization
Glad to hear that,

Best,
Daniel
Reply all
Reply to author
Forward
0 new messages