enod / pyswip

Automatically exported from code.google.com/p/pyswip
MIT License
0 stars 0 forks source link

Can't find SWI-Prolog library in Homebrew's /usr/local #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. install SWI-Prolog with brew
2. download & install pyswip with "sudo python setup.py install"
3. try "from pyswip import Prolog"

What is the expected output? What do you see instead?
I expect a successful import. Instead I see this:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pyswip/__init__.py", line 29, in <module>
    from pyswip.prolog import Prolog
  File "pyswip/prolog.py", line 29, in <module>
    from pyswip.core import *
  File "pyswip/core.py", line 356, in <module>
    (_path, SWI_HOME_DIR) = _findSwipl()
  File "pyswip/core.py", line 319, in _findSwipl
    raise ImportError('Could not find the SWI-Prolog library in this '
ImportError: Could not find the SWI-Prolog library in this platform. If you are 
sure it is installed, please open an issue.

What version of the product are you using? On what operating system?
I am certain SWI-Prolog is installed. I'm using OS X 10.8.2, python 2.7.2, 
pyswip 0.2.3, swipl 6.2.3, and Homebrew 0.9.3.

Please provide any additional information below.
SWI-Prolog was install by Homebrew to /usr/local/bin/swipl.
It looks like the library is installed to:
/usr/local/lib/swipl-6.2.3/lib/x86_64-darwin12.2.1/libswipl.a
/usr/local/lib/swipl-6.2.3/lib/x86_64-darwin12.2.1/libswipl.dylib

Linking those files to /usr/local/lib/libswipl.dylib didn't help.

Original issue reported on code.google.com by alexchan...@gmail.com on 1 Jan 2013 at 12:32

GoogleCodeExporter commented 9 years ago
I have no access to OS X, so I may need some help to solve and test it.

Is swipl available in your PATH? If it is, could you please run {{{swipl 
-dump-runtime-variables}}} and paste the output here?

Original comment by rodrigo....@gmail.com on 1 Jan 2013 at 9:46

GoogleCodeExporter commented 9 years ago
Yes it's at /usr/local/bin/swipl. Here's the output:

$ swipl -dump-runtime-variables
CC="cc";
PLBASE="/usr/local/Cellar/swi-prolog/6.2.3/lib/swipl-6.2.3";
PLARCH="x86_64-darwin12.2.1";
PLLIBS="";
PLLIB="-lswipl";
PLCFLAGS="-fno-strict-aliasing -no-cpp-precomp -pthread -fno-common ";
PLLDFLAGS="-O2 -pthread  ";
PLSOEXT="dylib";
PLVERSION="60203";
PLSHARED="yes";
PLTHREADS="yes";

There's a large folder hierarchy under 
"/usr/local/Cellar/swi-prolog/6.2.3/lib/swipl-6.2.3", and 
"/usr/local/Cellar/swi-prolog/6.2.3/lib/swipl-6.2.3/lib/x86_64-darwin12.2.1" 
has several dylibs:

$ ls
cgi.dylib              odbc4pl.dylib          socket.dylib
crypt.dylib            pdt_console.dylib      ssl4pl.dylib
double_metaphone.dylib porter_stem.dylib      streaminfo.dylib
files.dylib            process.dylib          table.dylib
http_stream.dylib      protobufs.dylib        time.dylib
isub.dylib             rdf_db.dylib           turtle.dylib
json.dylib             readutil.dylib         uid.dylib
libswipl.a             rlimit.dylib           unicode4pl.dylib
libswipl.dylib         sgml2pl.dylib          unix.dylib
memfile.dylib          sha4pl.dylib           uri.dylib
mime.dylib             snowball.dylib         zlib4pl.dylib

Original comment by alexchan...@gmail.com on 2 Jan 2013 at 4:25

GoogleCodeExporter commented 9 years ago
I committed a patch in r130. Could you please test it?

You can download the trunk with:
svn checkout http://pyswip.googlecode.com/svn/trunk/ pyswip-read-only

Thank you!

Original comment by rodrigo....@gmail.com on 2 Jan 2013 at 1:31

GoogleCodeExporter commented 9 years ago
The import succeeds, but now there's another issue. When I run the Send Money 
example code given in the wiki, python crashes with "Segmentation fault: 11" as 
soon as this line is executed:

for result in prolog.query("sendmore(X)"):
    r = result["X"]
    for i, letter in enumerate(letters):
        print letter, "=", r[i]

I also get a popup error window saying "Python quit unexpectedly while using 
the libswipl.dylib plug-in". I've attached the much longer crash-diagnostic 
information that accompanies this popup.

I double checked, and the money.pl Prolog code is correct, as is the Python 
code. The "prolog = Prolog()" line and the "prolog.consult('money.pl')" both 
succeed, but the prolog.query method appears to cause this fault.

I can open a separate issue if you like.

Original comment by alexchan...@gmail.com on 7 Jan 2013 at 1:10

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry for the late reply.

Thank you for your tests. I will close this issue and reopen issue 1, pointing 
to your crash dump. I will see if I can reproduce it in my environment (these 
64bit-related errors are very difficult to reproduce sometimes...)

Original comment by rodrigo....@gmail.com on 20 Jan 2013 at 1:45

GoogleCodeExporter commented 9 years ago
I committed some changes that may fix your problem (and it is "may" because I 
was not able to reproduce it exactly, but I got a Windows machine to generate a 
similar problem). Would you mind testing it and then making a comment on issue 
1 about the result? Thank you.

Original comment by rodrigo....@gmail.com on 20 Jan 2013 at 8:35