pyswip
pyswip copied to clipboard
Error when importing PySwip
I get this error whenever I try to run from pyswip import Prolog
>>> from pyswip import Prolog
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyswip/__init__.py", line 29, in <module>
from pyswip.prolog import Prolog
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyswip/prolog.py", line 28, in <module>
from pyswip.core import *
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyswip/core.py", line 568, in <module>
(_path, SWI_HOME_DIR) = _findSwipl()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyswip/core.py", line 417, in _findSwipl
(path, swiHome) = _findSwiplDar()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyswip/core.py", line 371, in _findSwiplDar
(path, swiHome) = _findSwiplFromExec()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyswip/core.py", line 93, in _findSwiplFromExec
rtvars = dict((name, value[1:-1]) for name, value in ret) # [1:-1] gets
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pyswip/core.py", line 93, in <genexpr>
rtvars = dict((name, value[1:-1]) for name, value in ret) # [1:-1] gets
ValueError: not enough values to unpack (expected 2, got 1)
I use Prolog 7.6.4 Python 3.8 and macOS
I face the same problem but with swipl 8.0.3, python 3.8 macOS Mojave (10.14.6). So pyswip is unusable for me at this point :-(.
I actually solved this problem, So first of all I had to use swipl 7.6.4 as that's the one that will work with macOS Mojave so you should downgrade to the 7.6.4 version and then try running the following commands:
export PATH=$PATH:/Applications/SWI-Prolog.app/Contents/swipl/bin/x86_64-darwin15.6.0export DYLD_FALLBACK_LIBRARY_PATH=/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin15.6.0
I actually don't remember if that's all I needed for it to get working or not but I'm pretty sure that these steps helped. So if that didn't work tell me so I can remember what other steps needed.
What worked for me was that I had to import swi-prolog using Homebrew as explained in this article: https://www.swi-prolog.org/build/macos.html
I was able to figure this out by reading the _findSwiplFromExec() function in the core.py file and turns out this error was because swi-prolog was not installed on my local system
I actually solved this problem, So first of all I had to use swipl 7.6.4 as that's the one that will work with macOS Mojave so you should downgrade to the 7.6.4 version and then try running the following commands:
export PATH=$PATH:/Applications/SWI-Prolog.app/Contents/swipl/bin/x86_64-darwin15.6.0export DYLD_FALLBACK_LIBRARY_PATH=/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin15.6.0I actually don't remember if that's all I needed for it to get working or not but I'm pretty sure that these steps helped. So if that didn't work tell me so I can remember what other steps needed.
How to this the problem, i tried the solution you wrote but its not working.
What worked for me was that I had to import
swi-prologusing Homebrew as explained in this article: https://www.swi-prolog.org/build/macos.htmlI was able to figure this out by reading the
_findSwiplFromExec()function in thecore.pyfile and turns out this error was because swi-prolog was not installed on my local system
This fixed it for me. Maybe the INSTALL README should reflect that this is the best way to install SWIPL on Mac?
I am having the same issues as described above, I am struggling with trying to solve the issue and my tutors at University don't seem to know how to use it! I am using swi-prolog 9 and pyswip in my project, any help would be much appreciated