Aluriak / clyngor

Handy python wrapper around Potassco's Clingo ASP solver.
GNU General Public License v3.0
34 stars 7 forks source link

AttributeError: module 'clingo' has no attribute 'Control' #28

Open jpsiegel opened 3 years ago

jpsiegel commented 3 years ago

Hello, I tried running your example use for clyngor and it raised this error. Its weird since if I try to use clingo python API example it also raises an error for clingo.Control() Any ideas? Im really looking forward to use clyngor in a production enviroment

Aluriak commented 3 years ago

Hello ! I do not know why you closed that issue, nor what is the error you found.

Can you provide the exact source code you used ?

Derfies commented 3 years ago

Hi @Aluriak, I've just run into the same issue. Ran pipenv install clyngor to add the package to a venv, then ran the first sample on pypi page, ie:

from clyngor import ASP, solve

answers = ASP("""
rel(a,(c;d)). rel(b,(d;e)).
obj(X):- rel(X,_) ; rel(X,Y): att(Y).
att(Y):- rel(_,Y) ; rel(X,Y): obj(X).
:- not obj(X):obj(X).
:- not att(Y):att(Y).
""")
for answer in answers:
    print(answer)

full traceback is:

"C:\Users\Jamie Davies\.virtualenvs\reactor-iED7jNFQ\Scripts\python.exe" test_clingo.py
Traceback (most recent call last):
  File "test_clingo.py", line 4, in <module>
    answers = ASP("""
  File "C:\Users\Jamie Davies\.virtualenvs\reactor-iED7jNFQ\lib\site-packages\clyngor\inline.py", line 17, in ASP
    return solve(inline=source_code, stats=False, **kwargs)
  File "C:\Users\Jamie Davies\.virtualenvs\reactor-iED7jNFQ\lib\site-packages\clyngor\solving.py", line 98, in solve
    ctl = clyngor.clingo_module.Control(options)
AttributeError: module 'clingo' has no attribute 'Control'

Process finished with exit code 1
Derfies commented 3 years ago

Adding use_clingo_module=False and setting clingo_bin_path seems to work when using my own binaries.

Aluriak commented 3 years ago

Thank you for your feedback !

Oh, yes. By default, clingo module is used if available. That behavior is however quite unexpected. I should change that.

Thanks for pointing this out. You should use use_clingo_module=False everywhere from now, unless you want to use the python clingo module compiled along clingo when building clingo from sources.