# I am having error with janus

**URL:** <https://swi-prolog.discourse.group/t/i-am-having-error-with-janus/8942>\
**Category:** Help!\
**Tags:** how-to, software\
**Created:** [April 17, 2025, 1:05am UTC](https://swi-prolog.discourse.group/t/i-am-having-error-with-janus/8942 "2025-04-17T01:05:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![R99](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/r99/32/7117_2.png) [@R99](https://swi-prolog.discourse.group/u/R99)\
**Post date:** [April 17, 2025, 1:05am UTC](https://swi-prolog.discourse.group/t/i-am-having-error-with-janus/8942/1 "2025-04-17T01:05:20Z")

</div>

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

```prolog
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

```prolog
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)

```prolog
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.

```prolog
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)](https://github.com/SWI-Prolog/packages-swipy/issues/14#issuecomment-2531047164)”. 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](https://swi-prolog.discourse.group/t/janus-and-conda/7775) 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.

---

<div class="post-metadata">

**Author:** ![friguzzi](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/friguzzi/32/7045_2.png) [@friguzzi](https://swi-prolog.discourse.group/u/friguzzi)\
**Post date:** [April 17, 2025, 5:47am UTC](https://swi-prolog.discourse.group/t/i-am-having-error-with-janus/8942/2 "2025-04-17T05:47:37Z")

</div>

Have you tried installing SWIPL from the sources at [GitHub - SWI-Prolog/swipl-devel: SWI-Prolog Main development repository](https://github.com/SWI-Prolog/swipl-devel) ?  
Using the instructions at [swipl-devel/CMAKE.md at ff1c2009545e0ec1cf21a0c83d54ddb0e3e4192c · SWI-Prolog/swipl-devel · GitHub](https://github.com/SWI-Prolog/swipl-devel/blob/ff1c2009545e0ec1cf21a0c83d54ddb0e3e4192c/CMAKE.md)  
and in particolar [swipl-devel/CMAKE.md at ff1c2009545e0ec1cf21a0c83d54ddb0e3e4192c · SWI-Prolog/swipl-devel · GitHub](https://github.com/SWI-Prolog/swipl-devel/blob/ff1c2009545e0ec1cf21a0c83d54ddb0e3e4192c/CMAKE.md#finding-requirements) I was able to run Janus. See also [Janus and Conda](https://swi-prolog.discourse.group/t/janus-and-conda/7775)

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [April 17, 2025, 7:09am UTC](https://swi-prolog.discourse.group/t/i-am-having-error-with-janus/8942/3 "2025-04-17T07:09:02Z")

</div>

Just to be clear the Python Janus package and the Prolog Janus library are distinct systems. Once installed and loaded they do the same thing and only differ in whether you load Prolog into Python or Python into Prolog. The Prolog library is part of the Prolog installation. Not all binary installers will provide it, but you didn’t tell us how you installed Prolog or on what platform.

---

<div class="post-metadata">

**Author:** ![R99](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/r99/32/7117_2.png) [@R99](https://swi-prolog.discourse.group/u/R99)\
**Post date:** [April 18, 2025, 2:29am UTC](https://swi-prolog.discourse.group/t/i-am-having-error-with-janus/8942/4 "2025-04-18T02:29:29Z")

</div>

@friguzzi @jan Thank you so much for you guidance. I previously had swi\_prolog\_9.3.0 build by compiling swipl-devel as you have mentioned in the comment @friguzzi. Then I tried few options like installing janus using standard

> pip install janus-swi

. But this did not seem to be working. Then I also tried installing inside swipl prolog directory packagaes/wipy folder using

> pip install .

which also failed. Then I also tried installing using

> pip install git+https://github.com/SWI-Prolog/packages-swipy.git#egg=janus\_swi.

This also failed. But lastly I again downloaded different version swipl\_prolog\_9.3.3, compiled it and installed janus inside its package folder and then

> janus-swi version 1.1.4

was installed. Then once I added it to my

> export SWI\_HOME\_DIR=$HOME/swi-prolog-9.3.3-janus/lib/swipl.

It seems to be working. Thank you so much for you help.

Note: There might be other changes between this versions but main change was in **init**.py in janus with added

swipl.call(“(exists\_source(library(janus))-\>true;asserta(user:file\_search\_path(library, Here)))”,  
{“Here”:os.path.dirname( **file** )})

which seemed to have helped.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [April 18, 2025, 7:13am UTC](https://swi-prolog.discourse.group/t/i-am-having-error-with-janus/8942/5 "2025-04-18T07:13:26Z")

</div>

> [@R99](#):
>
> swipl\_prolog\_9.3.3,

If you install from source anyway, why not install the latest version (9.3.22)? Quite a few Janus related things have been fixed and improved.

---

<div class="post-metadata">

**Author:** ![R99](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/r99/32/7117_2.png) [@R99](https://swi-prolog.discourse.group/u/R99)\
**Post date:** [April 18, 2025, 1:18pm UTC](https://swi-prolog.discourse.group/t/i-am-having-error-with-janus/8942/6 "2025-04-18T13:18:31Z")

</div>

Just to confirm it would install janus-swi version 1.5.2 ? Because with pip install it installed 1.5.2 and It was giving me error to get started with so I tried to skip it.

---

<div class="post-metadata">

**Author:** ![jan](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/jan/32/4_2.png) [@jan](https://swi-prolog.discourse.group/u/jan)\
**Post date:** [April 18, 2025, 2:23pm UTC](https://swi-prolog.discourse.group/t/i-am-having-error-with-janus/8942/7 "2025-04-18T14:23:06Z")

</div>

The current bundled source for Janus is at 1.5.2. There is only a patch to the docs since. If you install Prolog from source and the Python library can by found by CMake, you get a Prolog system that can call Python. On most systems, a subsequent `pip install .` in `packages/swipy` should allow loading Prolog into Python.

If things go wrong, please include the error message. If there are a lot (quite common), the first couple typically suffice.

---

<div class="post-metadata">

**Author:** ![R99](https://yyz2.discourse-cdn.com/free1/user_avatar/swi-prolog.discourse.group/r99/32/7117_2.png) [@R99](https://swi-prolog.discourse.group/u/R99)\
**Post date:** [May 11, 2025, 10:25pm UTC](https://swi-prolog.discourse.group/t/i-am-having-error-with-janus/8942/8 "2025-05-11T22:25:31Z")

</div>

@jan sorry for late reply. It seems to work with 9.3.22 while building from scratch without errors.
