yuce / pyswip

PySwip is a Python-Prolog interface that enables querying SWI-Prolog in your Python programs.
https://pyswip.org
MIT License
482 stars 98 forks source link

pyswip incompatible with swi-prolog 9.0.0? #146

Closed AmrSol closed 1 month ago

AmrSol commented 2 years 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 2 years 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 2 years ago

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

AmrSol commented 2 years ago

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

AmrSol commented 2 years 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 2 years ago

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

joyofdata commented 1 year 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 month ago

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