My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
INSTALL  
Install instructions for Linux and Win32
Featured, Phase-Deploy
Updated Feb 4, 2010 by yucete...@gmail.com

PySWIP INSTALL

(Updated for version 0.2)

PySWIP requires SWI-Prolog as a shared library since it uses ctypes to access SWI-Prolog/C functions. The shared library is present in 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 and libgmp (not required for basics).

You need to do the following to install a shared library enabled version of SWI-Prolog. We use version 5.6.34 of SWI-Prolog but any other recent version should work fine. Please make the necessary modifications for your environment.

  1. Get the source from: http://www.swi-prolog.org/download.html:
  2. $ wget http://gollem.science.uva.nl/cgi-bin/nph-download/SWI-Prolog/pl-5.6.34.tar.gz
  3. Extract the archive and cd into it:
  4. $ tar xzvf pl-5.6.34.tar.gz
    $ cd pl-5.6.34
  5. Configure the source with shared library enabled:
  6. $ ./configure --prefix=/usr --enable-shared
  7. Compile the source:
  8. $ make
  9. Install the source:
  10. $ sudo make install
  11. clp library is useful for constraint handling problems, so let's install it too:
  12. $ cd cd packages/clpqr
    $ ./configure --prefix=/usr --enable-shared
    $ make && sudo make install
  13. Create a soft link:
  14. $ sudo ln -s  /usr/lib/pl-5.6.34/lib/i686-linux/libpl.so.5.6.34 /usr/lib/libpl.so
  15. Next, get and install ctypes from: http://starship.python.net/crew/theller/ctypes . Note that you don't need to install it if you are using Python 2.5.
  16. Unpack PySwIP package and install it with, python setup.py install.
  17. $ tar xzvf pyswip-X.X.X
    $ sudo python setup.py install
  18. After you install it, you can test it with the following at your Python shell::
  19. >>> 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 share library. Check your default library directory (usually /usr/lib) for libpl.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:
  5. >>> from pyswip import Prolog
    >>> prolog = Prolog()
    >>> prolog.assertz("father(michael,john)")
Comment by loriaCar...@gmail.com, Feb 23, 2010

Running on Vista I got the problem even though libpl.dll (SWI-Prolog 5.6.64) is is actually registered path. Any idea? Thanks in advance

Comment by Eruy...@gmail.com, Sep 9, 2010

wget http://gollem.science.uva.nl/cgi-bin/nph-download/SWI-Prolog/pl-5.6.34.tar.gz will give a timeout error and I guess 5.6.34 does not exist anymore.

Using the latest instead (5.10.1) and doing a softlink from /usr/lib/swipl-5.10.1/lib/i686-linux/libswipl.so to /usr/lib/libpl.so seems to work for me.

Comment by seirey.i...@gmail.com, May 6, 2011

Please, anyone knows another place to download the 5.6.34 Prolog's version? The latest (5.10.x) is not working!

Comment by seirey.i...@gmail.com, May 6, 2011

Eruyome, i did what you said, but it not works. When i run "from pyswip import Prolog" it asks for the "libpl" archive, but the name of what we use is "libswipl". What did you do?

Comment by infected...@gmail.com, Jun 24, 2011

The new versions (5.10.x) don't have libpl.dll :(

Comment by rye...@gmail.com, Sep 14, 2011

FIX FOR SWI-Prolog 5.10.x:

1. Navigate to the SWI-Prolog bin directory. On Windows this is C:\Program Files\pl\bin by default.

2. Copy "swipl.dll" and rename the copy to "libpl.dll"

3. Profit!

Comment by defun...@gmail.com, Oct 25, 2011

I cannot seem to run any prolog Query (under python 2.7\2.6\3.2..) Using windows, i installed using the instructions - and even the examples cannot run.

for example, running hanoi.py: hanoi.py", line 64, in main

list(prolog.query("hanoi(%d)" % N))
File "C:\Python27\lib\site-packages\pyswip\prolog.py", line 70, in call
while maxresult and PL_next_solution(swipl_qid):
WindowsError?: exception: access violation writing 0x00000001

Comment by makoe...@gmail.com, Dec 16, 2011

i cannot do any queries, it tells me that there is a QueryWrapper? ignored

Comment by animanma...@gmail.com, Mar 4, 2012

Here's what I did as of March 5th, 2012 to get this to work (in easy copy-and-paste format, for those brave enough to trust me ;P):

wget http://www.swi-prolog.org/download/stable/src/pl-6.0.2.tar.gz
tar xzvf pl-6.0.2.tar.gz
cd pl-6.0.2/
./configure --prefix=/usr --enable-shared
make && sudo make install
cd packages/clpqr/
./configure --prefix=/usr
make && sudo make install
sudo ln -s  /usr/lib/swipl-6.0.2/lib/i686-linux/libswipl.so /usr/lib/libpl.so
sudo ln -s  /usr/lib/swipl-6.0.2/lib/i686-linux/libswipl.so.6.0.2 /usr/lib/.
wget http://pyswip.googlecode.com/files/pyswip-0.2.2.zip
unzip pyswip-0.2.2.zip
cd pyswip-0.2.2/
sudo python setup.py install

Then fire up the Python shell and try out the example above and hopefully everything works! :D


Sign in to add a comment
Powered by Google Project Hosting