First example for swiplserver from documentation doesn't work - please help

Dear everyone,
I just installed swiplserver 1.0.2 using Python 3.10 (SWI Prolog 9.0.4, AMD 64 version) and then I tried the first example from the docu:

from swiplserver import PrologMQI, PrologThread

with PrologMQI() as mqi:
    with mqi.create_thread() as prolog_thread:
        result = prolog_thread.query("atom(a)")
        print(result)

But instead the expected “True” response I get this error message:

Prolog: ERROR: -g mqi_start: catch/3: Unknown procedure: mqi_start/0
Traceback (most recent call last):
  File "D:/SWIProlog/swiplservertest.py", line 3, in <module>
    with PrologMQI() as mqi:
  File "D:\Python310\lib\site-packages\swiplserver\prologmqi.py", line 326, in __enter__
    self.start()
  File "D:\Python310\lib\site-packages\swiplserver\prologmqi.py", line 428, in start
    raise PrologLaunchError("no port found in stdout")
swiplserver.prologmqi.PrologLaunchError: no port found in stdout

mqi_start in the Interpreter runs and gives the result true.

I’m a little perplexed, because I think I did everything as stated in the documentation.

Could you, please, give me some hint?
Thx very much
Franz

1 Like

If mqi_start/0 is undefined we are dealing with an incomplete system. MQI is in library(mqi) and should be auto-loadable. From the path names this looks like you are using Windows? Installed from swi-prolog.org? My Windows VM is broken at the moment, so I can’t run a quick test. What happens if you run this in a Prolog console?

?- [library(mqi)].

If that works there is probably something wrong with the autoload index. You can fix that by starting swipl-win.exe with sufficient rights to write to the installation directories and type

?- make.
% Updating index for library ...

Should that fix things, please let us know because that means something is wrong with the distribution files.

1 Like

Thank you very much, I did as you told me and now it works:

After running make. the python shell gives me:

================== RESTART: D:\SWIProlog\swiplservertest.py ==================
True
>>> 

Thank you very much and
I hope it helps you to fix the distribution files.
:wink:

1 Like

And, finally, here the infos about my windows installation:

Edition Windows 10 Home
Version 22H2
Installiert am ‎16.‎08.‎2020
Betriebssystembuild 19045.2965
Leistung Windows Feature Experience Pack 1000.19041.1000.0
1 Like

Thanks. What actually matters here is not the Windows version, but which distribution you used. We have binaries for Windows on swi-prolog.org, but there are several other sites that provide SWI-Prolog installers for Windows, such as Portable Apps. In addition it can be built using MSYS2, Cygwin or WSL. I assume you are using the default installer from swi-prolog.org?