I’m using: SWI- Prolog version 9.3.0
I want the code to: run popper github: logic-and-learning-lab/Popper
I am having issue to run a code dependent on janus swi.
My installed version of janus is janus-swi-1.5.2.
It works fine when called separately from python
from janus_swi import query_once
print(query_once("member(X, [a,b,c])"))
{‘truth’: True, ‘X’: ‘a’}
But when I run with popper for the current version I see the error
ERROR: source_sink `library(janus)’ does not exist
Traceback (most recent call last):
File “/work/rp/HP/test_avi_prolog.py”, line 18, in
from heur.heur_utils import get_popper_examples, aggregate_all_solutions
File “/work/rp/HP/heur/heur_utils.py”, line 4, in
from popper.loop import learn_solution
File “/work/rp/HP/popper/popper/loop.py”, line 7, in
from . tester import Tester
File “/work/rp/HP/popper/popper/tester.py”, line 4, in
from janus_swi import query_once, consult
File “/work/rp/envs/rm_c117_py310_hp/lib/python3.10/site-packages/janus_swi/init.py”, line 23, in
_swipl.initialize(“swipl”,
janus_swi.janus.PrologError: Failed to load library(janus) into Prolog
This is my error from prolog environment
swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 9.3.0)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
1 ?- py_version.
ERROR: Unknown procedure: py_version/ 0 (DWIM could not correct goal)
2 ?- asserta(user:library_directory('/home/rp/swipl-9.3.0/packages/swipy'))
| .
true.
3 ?- use_module(library(janus)).
ERROR: source_sink `library(janus)’ does not exist
ERROR: In:
ERROR: [23] throw(error(existence_error(source_sink,…),_192))
ERROR: [18] ‘$resolve_source_path’(library(janus),_224,[if(not_loaded),…]) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:2503
ERROR: [17] ‘$load_file_e’(library(janus),user,[if(not_loaded),…]) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:2472
ERROR: [16] ‘$load_file’(library(janus),user,[if(not_loaded),…]) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:2439
ERROR: [11] toplevel_call(user:user: …) at /home/rp/.local/swi-prolog/lib/swipl/boot/toplevel.pl:1317
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
1 ?- debug.
true.
[debug] 2 ?- use_module(library(janus)).
ERROR: source_sink `library(janus)’ does not exist
ERROR: In:
ERROR: [23] throw(error(existence_error(source_sink,…),_328))
ERROR: [22] ‘$existence_error’(source_sink,library(janus)) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:4063
ERROR: [21] ‘$abs_file_error’(library(janus),,_400{access:read,file_type:prolog}) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:1325
ERROR: [20] ‘$absolute_file_name’(library(janus),_434,[file_type(prolog),…]) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:1311
ERROR: [19] absolute_file_name(library(janus),_482,[file_type(prolog),…]) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:1257
ERROR: [18] ‘$resolve_source_path’(library(janus),_530,[if(not_loaded),…]) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:2503
ERROR: [17] ‘$load_file_e’(library(janus),user,[if(not_loaded),…]) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:2472
ERROR: [16] ‘$load_file’(library(janus),user,[if(not_loaded),…]) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:2439
ERROR: [15] ‘$load_one_file’(library(janus),user,[if(not_loaded),…]) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:2277
ERROR: [14] ‘$load_files’(library(janus),user,[if(not_loaded),…]) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:2254
ERROR: [13] load_files(user:library(janus),[if(not_loaded),…]) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:2234
ERROR: [12] use_module(user:library(janus)) at /home/rp/.local/swi-prolog/lib/swipl/boot/init.pl:2172
ERROR: [11] toplevel_call(user:user: …) at /home/rp/.local/swi-prolog/lib/swipl/boot/toplevel.pl:1317
I also tried with earlier version of janus as suggested https:// github. com/SWI-Prolog/packages-swipy/tree/master
If you installed SWI-Prolog from source, it is advised to install Janus from the packages/swipy directory in the Prolog source. The package can be installed from within this directory using
So, I from my swipl-9.3.0/packages/swipy/janus I also tried
pip install .
which gives me error
python -c “import janus_swi; print(janus_swi.file)”
ERROR: source_sink `library(janus)’ does not exist
Traceback (most recent call last):
File “”, line 1, in
File “/home/rp/swipl-9.3.0/packages/swipy/janus/init.py”, line 18, in
_swipl.initialize(“swipl”,
janus.PrologError: Failed to load library(janus) into Prolog
which is not seen in current version with code
python -c “import janus_swi; print(janus_swi.file)”
/work/rp/envs/rm_c117_py310_hp/lib/python3.10/site-packages/janus_swi/init.py
The issue here seems to be similar to issue discussed in “#14 (comment)”. Here it is mentioned the issue is fixed but I am not sure why it is still occurring. Would really be grateful if you could help me navigate through the error. I wanted to use janus integrated in popper.
The os I am currenlty using is
NAME=“CentOS Linux”
VERSION=“7 (Core)”
ID=“centos”
ID_LIKE=“rhel fedora”
VERSION_ID=“7”
PRETTY_NAME=“CentOS Linux 7 (Core)”
ANSI_COLOR=“0;31”
CPE_NAME=“cpe:/o:centos:centos:7”
CENTOS_MANTISBT_PROJECT=“CentOS-7”
CENTOS_MANTISBT_PROJECT_VERSION=“7”
REDHAT_SUPPORT_PRODUCT=“centos”
REDHAT_SUPPORT_PRODUCT_VERSION=“7”
My python version is 3.10.13
My swi prolog version is 9.3.0
It seem to be running fine with my mac environment. The only difference in my environment and this is local environment runs on cpu and this on gpu.
I also tried Janus and Conda to see if it would help me with the issue. But I got
?- py_version.
ERROR: Unknown procedure: py_version/0 (DWIM could not correct goal)
It would be really helpful I could get insights on the issue.