Freely downloadable directly from swiprolog.org, stable version here, installs
into /Applications/SWI-Prolog.app/Contents/MacOS/
.
The SMT Parser uses the embedded Janus Python interface.
In the Terminal shell, type swipl
.
If not found, install it either from SWI Prolog directly, or Homebrew or MacPorts (see below). If installed but still not found, check yourPATH
. Shell commandecho $PATH
returns a colon (:) separated list of directories. If the Prolog directory is not present, you can add it for this session using Shell commandexport PATH=directory:$PATH
, where directory is replaced with the correct SWI Prolog directory for your installation, or place the command permanently in the startup file.bash_profile
in your home directory if Bash is your Shell program. If you use zsh instead, edit.zprofile
in your home directory instead. Then start up a new Terminal window and.bash_profile/.zprofile
will be read.
Banner below reveals the
version, here 9.2.6. Why do we care? Well, the Janus Python
interface is bundled with SWI Prolog, beginning with version 9.2.
The Prolog command ?- ensure_loaded(library(janus)).
loads the package.
$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 9.2.6)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- ensure_loaded(library(janus)).
true.
?-
Also, SWI Prolog is available on macOS from the brew package manager (brew.sh) eco-system,
see package swi-prolog here,
installing into /opt/homebrew/bin/
,
or MacPorts, see stable package here or
development version here,
installing into /opt/local/bin/
.
On versions earlier than 9.2, Janus is not present, e.g. see below:
$ /Applications/SWI-Prolog.app/Contents/MacOS/swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.4.3)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- ensure_loaded(library(janus)).
ERROR: source_sink `library(janus)' does not exist
ERROR: In:
ERROR: [20] throw(error(existence_error(source_sink,...),_20596))
ERROR: [16] '$resolve_source_path'(library(janus),_20628,[if(not_loaded)]) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:2428
ERROR: [15] '$load_file_e'(library(janus),user,[if(not_loaded)]) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:2404
ERROR: [14] '$load_file'(library(janus),user,[if(not_loaded)]) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:2373
ERROR: [9] toplevel_call(user:user: ...) at /Applications/SWI-Prolog.app/Contents/swipl/boot/toplevel.pl:1158
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
?-
By default, the SWI Prolog installer does not update the PATH.
On Windows PowerShell, see if the location of the swipl
executable is on the PATH using Get-Command
:
The installer stores the SWI Prolog executable as C:\Program
Files\swipl\bin\swipl.exe
. You can type the complete path as follows:
You can also add the directory C:\Program
Files\swipl\bin
to your PATH if it's not there. Alternatively,
you can run the SWI Prolog app directly from the Start menu.
Note: in the above picture, both nltk and nltk_data have already been installed separately.
Python itself can be installed from python.org directly
and is accessible as C:\Windows\py.exe
.
You can then run the command py
, as
C:\Windows\
is on the PATH, in a
PowerShell window. The command py -0p
will tell you where it finds
different versions of Python on your computer.
The package installer program pip
itself is installed under the
AppData\Programs\Python\Python312\
subdirectory of your
home directory. Get-command pip
should find
pip
if that directory is on your PATH.
To see the
PATH, $env:path
in PowerShell will show a semicolon (;) separated list
of directories.
nltk can be installed using pip install --user -U nltk
following using the instructions here, without using
Prolog's py_shell
to access the Janus embedded Python (as
described in the nltk install section).
Alternatively, called pip
from py
using
py -m pip install --user -U nltk
. Option -U
means
upgrade all packages, and --user
means install to your
local user directory.