74 lines
2.8 KiB
Plaintext
74 lines
2.8 KiB
Plaintext
PySWIP INSTALL
|
|
==============
|
|
|
|
PySWIP requires SWI-Prolog as a shared library since it uses ctypes to access SWI-Prolog/C functions. The shared library is present in the Win32 installer, but missing by default from the builds made directly from the source.
|
|
|
|
Installing on Linux
|
|
-------------------
|
|
|
|
These instructions are tested on a Linux system, but should also work for POSIX systems. Also, you may want to install development packages for readline, libncurses, and libgmp.
|
|
|
|
You need to do the following to install a shared library enabled version of SWI-Prolog. We use version 6.0.2 of SWI-Prolog. Please make the necessary modifications for your environment.
|
|
|
|
1) Get the source from http://www.swi-prolog.org/download/stable:
|
|
|
|
$ wget http://www.swi-prolog.org/download/stable/src/pl-6.0.2.tar.gz
|
|
|
|
2) Extract the archive and cd into it:
|
|
|
|
$ tar xzvf pl-6.0.2.tar.gz
|
|
$ cd pl-6.0.2.tar.gz
|
|
|
|
3) Configure the source with shared library enabled:
|
|
|
|
$ ./configure --enable-shared
|
|
|
|
*** If using a 64-bit system, you may have to compile with the -ggdb flag in order to get PySWIP to work with SWI-Prolog without segfaults (But not necessarily. YMMV.):
|
|
|
|
$ CFLAGS=-ggdb ./configure --enable-shared
|
|
|
|
4) Compile the source:
|
|
|
|
$ make
|
|
|
|
5) Install the source:
|
|
|
|
$ sudo make install
|
|
|
|
6) *** This is perhaps no longer relevant, as it appears clp is installed by default with SWI-Prolog
|
|
clp library is useful for constraint handling problems, so let's install that too:
|
|
|
|
$ cd cd packages/clpqr
|
|
$ ./configure --enable-shared
|
|
$ make && make install
|
|
|
|
7) If you are not using Python 2.5 or later, you should install ctypes, or get a new version of Python (apt-get is fine if you're using Ubuntu).
|
|
|
|
8) Unpack PySwIP package and install it with, ``python setup.py install``.
|
|
|
|
9) After you install it, you can test it with the following at your Python shell::
|
|
|
|
>>> from pyswip import Prolog
|
|
>>> prolog = Prolog()
|
|
>>> prolog.assertz("father(michael,john)")
|
|
|
|
If you get an error, such as "libpl (shared) not found." or "FATAL ERROR: Resource not found" be sure you have installed SWI-Prolog as a shared library. Check your default library directory (usually ``/usr/lib``) for ``libswipl.so``.
|
|
|
|
|
|
Installing on Win32
|
|
-------------------
|
|
|
|
1) Get a recent version of SWI-Prolog for Win32 from: http://www.swi-prolog.org/dl-stable.html and install it.
|
|
|
|
2) You need to add SWI-Prolog's bin directory ``C:\Program Files\pl\bin`` to *path*, here are two tutorials for that: http://www.computerhope.com/issues/ch000549.htm and http://vlaurie.com/computers2/Articles/environment.htm
|
|
|
|
3) Get a Windows installer version of PySWIP and install it.
|
|
|
|
4) After you install it, you can test it with the following at your Python console::
|
|
|
|
>>> from pyswip import Prolog
|
|
>>> prolog = Prolog()
|
|
>>> prolog.assertz("father(michael,john)")
|
|
|
|
|