Consult method doesn't work

131 views
Skip to first unread message

Ольга Чебан

unread,
May 16, 2019, 5:25:45 AM5/16/19
to pyswip
Hello, everyone!

I'm trying to use prolog file in Python and get problem of existence prolog file. 
I'm doing the following:

from pyswip import Prolog

        prolog= Prolog()
        prolog.consult('myfile.pl')

It's working only in one threaded app, but I have a multithreaded app, that's why I have some problems, I think.

Error:
[31;1mERROR: source_sink `'myfile.pl'' does not exist

After that goes traceback and at the end it shows the following:

pyswip.prolog.PrologError: Caused by: 'consult('myfile.pl')'. Returned: 'error(2)'.

Does anyone know how to fix that?

Nicolas Gallinal

unread,
Jul 24, 2019, 2:04:09 PM7/24/19
to pyswip
I was experiencing the same issue just now using Visual Studio Code.

If I run it directly saying python -u main.py it works but inside VSC it didn't.

Adding the following configuration to launch.json does the trick assuming your main file is main.py and the prolog file is on the same directory (src).

{
"name": "Python: Current File (Integrated Terminal)",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/src/main.py",
"console": "integratedTerminal",
"cwd":"${workspaceFolder}/src"
}

Let me know if it works for you.
Reply all
Reply to author
Forward
0 new messages