yuce / pyswip

PySwip is a Python - SWI-Prolog bridge enabling to query SWI-Prolog in your Python programs. It features an (incomplete) SWI-Prolog foreign language interface, a utility class that makes it easy querying with Prolog and also a Pythonic interface.
https://pyswip.org
MIT License
472 stars 97 forks source link

pyswip incompatible with swi-prolog 9.0.0? #146

Closed AmrSol closed 1 week ago

AmrSol commented 1 year ago

I updated my brew formulas including swi-prolog (from 8.4.x to 9.0.0) and my codebase no longer works. I get this error:

File "/Users/amrsoliman/miniforge3/envs/M1/lib/python3.9/site-packages/pyswip/prolog.py", line 156, in consult next(cls.query(filename.join(["consult('", "')"]), catcherrors=catcherrors)) File "/Users/amrsoliman/miniforge3/envs/M1/lib/python3.9/site-packages/pyswip/prolog.py", line 126, in call raise PrologError("".join(["Caused by: '", query, "'. ", pyswip.prolog.PrologError: Caused by: 'consult('train.pl')'. Returned: 'error(instantiation_error, context(:(system, /(atom_chars, 2)), _3208))'.

Is there some sort of incompatibility between pyswip and swi-prolog 9.0.0?

AmrSol commented 1 year ago

It seems like this thread could be of great use to the problem:

https://swi-prolog.discourse.group/t/best-easiest-way-to-downgrade-to-version-8-4-3-on-linux-ubuntu-20-04/5966

crgz commented 1 year ago

Thanks @AmrSol ! The problem will be fixed with PR: #145.

AmrSol commented 1 year ago

Hey @crgz . I see that PR: #145 has been merged. Consequently, I did the following:

AmrSol commented 1 year ago

It finally works! The thread suggested above was very useful. Here is how:

For some reason downloading SWI-Prolog 8.4.3 from the website is causing me another slew of errors. Therefore I went back to SWI-Prolog 9.x via homebrew.

By implementing D.Cox’s pyswip PR #133, I get the “Exception: swi-prolog version number could not be determined”.

Then I implemented @hakank 's suggestion by amending Cox’s “PL_version = _lib.PL_version” to “PL_version = _lib.PL_version_info”

Viola! Thankfully, it works! In case anyone is curious, I have been using Aleph.

craigpastro commented 1 year ago

Hello 👋 I've run into the same problem. @AmrSol's solution above is working for me for the moment. Thanks!

joyofdata commented 11 months ago

Hey @crgz . I see that PR: #145 has been merged. Consequently, I did the following:

* "pip uninstall pyswip"

* "pip install git+https://github.com/yuce/pyswip@master#egg=pyswip" and got the latest version.
  Unfortunately, I get the same error as above...

Works for me!

image

But - I would assume that instantiating a new Prolog object will start a fresh and empty database. Instead asserts are piling up.

yuce commented 1 week ago

Latest release v0.3.0 should fix this issue. Please feel to reopen the issue if the problem persists.