Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unknown Error after installing CNApy-1.2.2 #528

Open
Smeegdelijk opened this issue Nov 13, 2024 · 6 comments
Open

Unknown Error after installing CNApy-1.2.2 #528

Smeegdelijk opened this issue Nov 13, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@Smeegdelijk
Copy link

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)

@Smeegdelijk Smeegdelijk added the bug Something isn't working label Nov 13, 2024
@Smeegdelijk Smeegdelijk changed the title Unknown Error while installing CNApy-1.2.2 Unknown Error after installing CNApy-1.2.2 Nov 13, 2024
@Paulocracy
Copy link
Member

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
Copy link
Author

Smeegdelijk commented Nov 13, 2024

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
Copy link
Member

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
Copy link
Author

Smeegdelijk commented Nov 14, 2024

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
Copy link
Member

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
Copy link
Author

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)

@axelvonkamp axelvonkamp pinned this issue Nov 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants