cnapy-org / CNApy

An integrated visual environment for metabolic modeling with common methods such as FBA, FVA and Elementary Flux Modes, and advanced features such as thermodynamic methods, extended Minimal Cut Sets, OptKnock, RobustKnock, OptCouple and more!
https://cnapy-org.github.io/CNApy-guide/
Apache License 2.0
46 stars 7 forks source link

Unknown Error after installing CNApy-1.2.2 #528

Open Smeegdelijk opened 2 weeks ago

Smeegdelijk commented 2 weeks ago

Describe the bug After installing CNApy either with install_cnapy_here using the CNApy installer or installing CNApy using conda (3rd option as described here: https://github.com/cnapy-org/CNApy/blob/master/README.md#installation-options ) I get the following error when I try to lauch/ run CNApy:

image

Is this an actual bug or am I doing something wrong?

Error message in text:

Traceback (most recent call last): File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\cnapy__main.py", line 37, in main_cnapy() File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\cnapy__main__.py", line 34, in main_cnapy Application() File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\cnapy\application.py", line 76, in init self.window = MainWindow(self.appdata) File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\cnapy\gui_elements\main_window.py", line 70, in init self.central_widget = CentralWidget(self) File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\cnapy\gui_elements\central_widget.py", line 72, in init self.reaction_list = ReactionList(self) File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\cnapy\gui_elements\reactions_list.py", line 148, in init__ self.reaction_mask = ReactionMask(self) File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\cnapy\gui_elements\reactions_list.py", line 698, in init self.grp_test_model.add_reactions([reaction]) File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\cobra\core\model.py", line 757, in add_reactions self._populate_solver(pruned) File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\cobra\core\model.py", line 1132, in _populate_solver if reaction.id not in self.variables: File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\cobra\core\model.py", line 1017, in variables return self.solver.variables File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\optlang\interface.py", line 1239, in variables self.update() File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\optlang\gurobi_interface.py", line 666, in update super(Model, self).update(callback=self.problem.update) File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\optlang\interface.py", line 1464, in update self._add_constraints(add_constr) File "C:\Users\vkoselka\AppData\Local\anaconda3\envs\cnapy-1.2.2\lib\site-packages\optlang\gurobi_interface.py", line 723, in _add_constraints self.problem.addConstr(lhs, sense, rhs, name=constraint.name) File "src\gurobipy\_model.pyx", line 3894, in gurobipy._model.Model.addConstr TypeError: addConstr() takes at most 3 positional arguments (4 given)

Paulocracy commented 2 weeks ago

Thank you for submitting this issue :-) It looks like something is wrong with optlang's usage of Gurobi :O, maybe something changed in the gurobipy API, we'll check if we can reproduce it :3

In the meantime, you could try to use a different solver by switching, e.g., to GLPK or CPLEX (for the latter, keep in mind that only the small Community version is installed by default) in the cobrapy settings under "Config"->"Configure COBRApy..."

Smeegdelijk commented 2 weeks ago

Thanks for looking into it! Now that I think about it I should maybe mention that I do not have the latest version of gurobi installed, but I just tried installing CNApy on my personal laptop (where no gurobi is installed at all) and it gave me the same error. (once again after activating CNApy which was installed using the 3rd option as mentioned previously). If you want I can get back to you with the specific gurobi version that was installed on the other computer, but im not sure it will help much.

axelvonkamp commented 2 weeks ago

Can you launch a Python interpreter in your CNApy environment and execute the following commands:

model = cobra.Model(id_or_model="test")
reaction = cobra.Reaction('TEST')
metabolite = cobra.Metabolite('X')
reaction.add_metabolites({metabolite: -1})
model.add_reactions([reaction])

Does this work or do you get a similar error as above?

Smeegdelijk commented 2 weeks ago

I get the same error as above. image

If I run the following code the error does not appear:

`model = cobra.Model(id_or_model='test')

model.solver = 'glpk' reaction = cobra.Reaction('TEST') metabolite = cobra.Metabolite('X') reaction.add_metabolites({metabolite: -1}) model.add_reactions([reaction])`

axelvonkamp commented 2 weeks ago

Hi, the problem appears to be an incompatibility between optlang and Gurobi 12.0.0 (released two days ago). We are opening an issue in the optlang repository and hope they can fix it soon. For now you need to downgrade Gurobi to one of the 11.x versions until optlang has resolved the problem.

Smeegdelijk commented 2 weeks ago

Thanks! For anyone coming across this thread, after running:

pip install cnapy

run the following to fix the issue:

pip install gurobipy==11.0.3

Now you can safely launch CNApy by running:

cnapy

(https://github.com/cnapy-org/CNApy/blob/master/README.md#installation-options ) (3rd option)