Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

pyswip showing existence error for no apparent reason.

343 views
Skip to first unread message

Tanisha Bhayani

unread,
Apr 2, 2017, 11:13:40 PM4/2/17
to pyswip
I have a prolog file questionmap.pro which stores predicates like -
question(who,person). question(is,bool).

etc.; which I want to access through a python code, for which I am using pyswip. I used
p.query('[questionmap]')

and it works fine, but then when I query to get information like:
p.query('question(who,X)')

this does not show anything other than object information but when I create list out of this generator it shows me the following existence error:
>>> l = list(p.query('question(who,X)'))
Traceback (most recent call last):
 
File "<stdin>", line 1, in <module>
 
File "C:\Program Files\Python36-32\lib\site-packages\pyswip\prolog.py", line 1
27, in __call__
   
"Returned: '", str(term), "'."]))
pyswip
.prolog.PrologError: Caused by: 'question(who,X)'. Returned: 'error(existe
nce_error(procedure, /(question, 2)), context(/(pyrun, 2), _436))'
.
>>>
I checked it on internet but nothing shows in terms of pyswip. Also querying this file from swipl, shows no error. Plus I am running python from the directory which contains this prolog file. assertz is working and querying the rules which have being specified by the assertz works, so I think that it is the pyswip that is not able to load the file. Also tried using
p.query('consult[`questionmap.pro`]')

but results are the same.
Thanks in advance.

Rodrigo Starr

unread,
Apr 3, 2017, 5:26:30 AM4/3/17
to pys...@googlegroups.com
The file should be named questionmap.pl, not questionmap.pro.

A good way to help debugging this sort of stuff is running it on the swipl prompt. Also, you could have done:
list(p.query('[questionmap]'))

and see that questionmap was not found.

--
Rodrigo Rizzi Starr
--
You received this message because you are subscribed to the Google Groups "pyswip" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyswip+un...@googlegroups.com.
To post to this group, send email to pys...@googlegroups.com.
Visit this group at https://groups.google.com/group/pyswip.
For more options, visit https://groups.google.com/d/optout.

Tanisha Bhayani

unread,
Apr 3, 2017, 8:05:12 AM4/3/17
to pyswip
Thank You for the answer, .pl is for perl on my pc. I did l = list(p.query('[questionmap]')) and  printed l: [{}], but after this it queries to questionmap are running smoothly, but without creating list of generator object it doesn't work. Why? Is it because the interpreter removes the generator object from the memory?
Reply all
Reply to author
Forward
0 new messages