potassco / clingo

🤔 A grounder and solver for logic programs.
https://potassco.org/clingo
MIT License
589 stars 79 forks source link

Issues Running Python Inside Clingo - MacOs - M2 Chip #470

Closed ltran1612 closed 7 months ago

ltran1612 commented 7 months ago

Hi,

I'm having a freezing problem running the second example shown in https://potassco.org/clingo/python-api/current/clingo/:

#script (python)

from clingo.symbol import Number

class Context:
    def inc(self, x):
        return Number(x.number)

    def seq(self, x, y):
        return [x, y]

def main(prg):
    prg.ground([("base", [])], context=Context())
    prg.solve()

#end.

p(@inc(10)).
q(@seq(1,2)).

The Problem: Running the example got stuck at:

clingo version 5.6.2
Reading from test.lp

Setup: 1) Macbook Air M2. 2) OS: MacOS 14.1.1 (23B81) (Sonoma) 3) Clingo Version: 5.6.2 (installed through Brew) 4) Installed the "clingo" python package for both Brew's Python and MacOS's Python

I'm relatively new to Clingo, so I'm grateful if anyone can give me some suggestions on how to fix it.

Thank you in advance!

rkaminsk commented 7 months ago

The example should produce the following output:

$ clingo test.lp
clingo version 5.6.2
Reading from test.lp
Solving...
Answer: 1
p(10) q(1) q(2)
SATISFIABLE

Models       : 1+
Calls        : 1
Time         : 0.071s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s)
CPU Time     : 0.056s

We had so far no reports that there are issues with builds for MacOS. I have no idea what the problem could be. Maybe it is an issue with the homebrew formula. You could try whether the conda forge package works: https://anaconda.org/conda-forge/clingo.

ltran1612 commented 7 months ago

Thank you for the prompt response!

The clingo installed through conda works. Maybe some configuring setting was required for brew's clingo.

GBisi commented 6 months ago

Hi, I had the same problem with my Macbook M3 with MacOS 14.2.1 and clingo 5.6.2 installed with brew. I also confirm that the conda version seems working properly.

rkaminsk commented 6 months ago

I do not have access to an M3 Macbook and cannot debug this. Maybe ask for help on the homebrew issue tracker: https://docs.brew.sh/Troubleshooting#create-an-issue.