This guide will help you set up SWI-Prolog on your Mac using Homebrew, install PySwip using pip, set up a virtual Python environment, and run a Python script named main.py
.
- SWI-Prolog
- Python 3
- PySwip
Open your terminal and execute the following command to install SWI-Prolog using Homebrew:
brew install swi-prolog
cd path/to/your/project
python -m venv env
source env/bin/activate
pip install -r requirements.txt
If everything runs fine you should see an error aboaut some variables not being instantiated properly. This is a versioning issue and to solve open the venv folder created, open the pyswip folder within it and open the core.py file there. Ctlr + F for PL_version and change the line for the one below.
PL_version = _lib.PL_version_info
If that does not work don't worry. You can still run the program on google colab just click on the link below.
https://colab.research.google.com/drive/1df2BEAbkGOvDMcXBsttCZO5H0anWZje9?usp=sharing
All you need to do is upload the study_KB.pl into colab and the program should work as expected.
python main.py
If everything runs fine you should see an error aboaut some variables not being instantiated properly. This is a versioning issue and to solve open the venv folder created, open the pyswip folder within it and open the core.py file there. Ctlr + F for PL_version and change the line for the one below.
PL_version = _lib.PL_version_info