Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest supported version of swi-prolog? #17

Closed
farcepest opened this issue Oct 6, 2017 · 9 comments
Closed

Latest supported version of swi-prolog? #17

farcepest opened this issue Oct 6, 2017 · 9 comments
Assignees

Comments

@farcepest
Copy link

I'm tinkering with pyswip and swi-prolog-7.4.2, and so far, it seems to always segfault. What versions do you support at this point?

@farcepest
Copy link
Author

I'll also note, swi-prolog-7.4.2 from brew on Mac OS X, plus some symlinks so that pyswip can find libpl.dylib

@farcepest
Copy link
Author

running under ldd, here's where it dies:

Python 2.7.13 (default, Dec 18 2016, 07:03:39) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import father
>>> father.main()
:- dynamic father/2.

father(john, mich).
father(john, gina).

Process 74699 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x561910)
    frame #0: 0x0000000102116f59 libpl.dylib`PL_get_functor__LD + 187
libpl.dylib`PL_get_functor__LD:

@JoaoFelipe
Copy link

I usually try to install swipl 5.6, as it is the explicit version cited in the readme.
But I recall having success with a 6.x version (maybe 6.2).

@PaulBrownMagic
Copy link
Contributor

I'm on "SWI-Prolog version 7.6.4 for amd64", Ubuntu box, no problems here.

@yuce yuce self-assigned this May 20, 2018
@yuce
Copy link
Owner

yuce commented Jun 7, 2018

Latest PySwip runs fine with the latest stable SWI-Prolog (7.6.x) on MacOS, Linux and Windows. INSTALL.md is up-to-date with the latest instructions.

@yuce yuce closed this as completed Jun 7, 2018
@bigstas
Copy link

bigstas commented May 13, 2019

Is Prolog version 8 supported? I get the following:
(first, asking for a version number)
Please enter you SWI-Prolog version in format "X.Y.Z": (my response) 8.0.2
(then, an error)

  File "prolog/difficulty.py", line 1, in <module>
    from pyswip import Prolog
  File "/usr/local/lib/python3.6/site-packages/pyswip/__init__.py", line 29, in <module>
    from pyswip.prolog import Prolog
  File "/usr/local/lib/python3.6/site-packages/pyswip/prolog.py", line 28, in <module>
    from pyswip.core import *
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 568, in <module>
    (_path, SWI_HOME_DIR) = _findSwipl()
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 420, in _findSwipl
    (path, swiHome) = _findSwiplMacOSHome()
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 342, in _findSwiplMacOSHome
    swi_ver = get_swi_ver()
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 310, in get_swi_ver
    match = re.search(r'[0-9]\.[0-9]\.[0-9]')
TypeError: search() missing 1 required positional argument: 'string'

I get the same error whether I write "8.0.2" or 8.0.2 (without quotation marks) in the prompt.
It seems like it can't see that I've written any input though - the re.search doesn't have positional argument: 'string'? (Last line of traceback)

I've checked that my swipl is accessible in my PATH variable.

@bigstas
Copy link

bigstas commented May 13, 2019

I dug into this a bit. The re.search function requires a string to do its regexp search on (obviously, in retrospect), which is why the above error was being thrown. Consider solving this with the following change in core.py:
match = re.search(r'[0-9]\.[0-9]\.[0-9]',swi_ver)
It looks to me that that was originally intended, otherwise the swi_ver variable is not used.

Re-running the command, I get the following error:

Please enter you SWI-Prolog version in format "X.Y.Z": 8.0.2
Traceback (most recent call last):
  File "prolog/difficulty.py", line 1, in <module>
    from pyswip import Prolog
  File "/usr/local/lib/python3.6/site-packages/pyswip/__init__.py", line 29, in <module>
    from pyswip.prolog import Prolog
  File "/usr/local/lib/python3.6/site-packages/pyswip/prolog.py", line 28, in <module>
    from pyswip.core import *
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 568, in <module>
    (_path, SWI_HOME_DIR) = _findSwipl()
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 420, in _findSwipl
    (path, swiHome) = _findSwiplMacOSHome()
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 349, in _findSwiplMacOSHome
    (path_res, back_path) = walk(path, name)
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 295, in walk
    for dir_ in os.listdir(back_path):
FileNotFoundError: [Errno 2] No such file or directory: '/Applications/SWI-Prolog.app/Contents/swipl-8.0.2/lib/'

...and indeed, I have no file or directory suffixed with the version number; instead, I have the following path:
/Applications/SWI-Prolog.app/Contents/swipl/lib
... So all I had to do was comment out this bit of code in core.py:

if match is None:                                                                                                                                 
        raise InputError('Error, type normal version')

...and not type in any version number when prompted.

But then I get this error:

Please enter you SWI-Prolog version in format "X.Y.Z": 
Traceback (most recent call last):
  File "prolog/difficulty.py", line 1, in <module>
    from pyswip import Prolog
  File "/usr/local/lib/python3.6/site-packages/pyswip/__init__.py", line 29, in <module>
    from pyswip.prolog import Prolog
  File "/usr/local/lib/python3.6/site-packages/pyswip/prolog.py", line 28, in <module>
    from pyswip.core import *
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 568, in <module>
    (_path, SWI_HOME_DIR) = _findSwipl()
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 420, in _findSwipl
    (path, swiHome) = _findSwiplMacOSHome()
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 349, in _findSwiplMacOSHome
    (path_res, back_path) = walk(path, name)
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 295, in walk
    for dir_ in os.listdir(back_path):
FileNotFoundError: [Errno 2] No such file or directory: '/Applications/SWI-Prolog.app/Contents/swipl-/lib/'

That's because it's concatenating swipl- with None (as I didn't insert a version number), but my folder isn't swipl- but swipl.

Then I noticed how this code is being used:

path = os.environ.get('SWI_HOME_DIR')
    if path is None:
        path = os.environ.get('SWI_LIB_DIR')
        if path is None:
            path = os.environ.get('PLBASE')
            if path is None:
                swi_ver = get_swi_ver()
                path = '/Applications/SWI-Prolog.app/Contents/swipl-' + swi_ver + '/lib/'

So I decided to add a SWI_HOME_DIR in my .profile:
export SWI_HOME_DIR=/Applications/SWI-Prolog.app/Contents/swipl/lib/
That now gives me this error:

[FATAL ERROR: at Mon May 13 11:10:06 2019
	Could not find system resources]
Traceback (most recent call last):
  File "prolog/difficulty.py", line 1, in <module>
    from pyswip import Prolog
  File "/usr/local/lib/python3.6/site-packages/pyswip/__init__.py", line 29, in <module>
    from pyswip.prolog import Prolog
  File "/usr/local/lib/python3.6/site-packages/pyswip/prolog.py", line 28, in <module>
    from pyswip.core import *
  File "/usr/local/lib/python3.6/site-packages/pyswip/core.py", line 573, in <module>
    _lib = CDLL(_path, mode=RTLD_GLOBAL)
  File "/usr/local/Cellar/python/3.6.4_4/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin15.6.0/libswipl.dylib, 10): Library not loaded: @executable_path/../swipl/lib/x86_64-darwin15.6.0/libncurses.6.dylib
  Referenced from: /Applications/SWI-Prolog.app/Contents/swipl/lib/x86_64-darwin15.6.0/libswipl.dylib
  Reason: image not found

This is where I stopped for now.

@mstfymrtc
Copy link

@yuce I'm having the same issue, do you have any suggestions? Thanks.

@jtank38
Copy link

jtank38 commented Apr 28, 2020

same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants