After reading the README of Janus-SWI GitHub - SWI-Prolog/packages-swipy: Python interface for SWI-Prolog , I am still unsure how to embed Python into Prolog on MacOS. Do I need to install a Homebrew or Macports version of Python, in order to embed Python into Prolog?
My current Python was not installed through Homebrew or Macports. When I use ?- py_version. I get ERROR: Unknown procedure: janus:py_call/2.
Is it simply because I am not using a Homebrew/Macports version of Python, or something else that I missed doing?
For short, you need the thing that provides the Python framework, which is provided by the official installer from Python.org (version 3.11).
Alternatively, the simplest is to use Macports and install SWI-Prolog 9.3.19 (devel). That will install Macports Python as a dependency and all should work out of the box.
As is, library(janus) is only built as part of a full build of SWI-Prolog. Possibly we should seek for some way to simplify dealing with the dependencies. I’m not sure how though. We could distribute an object file that relies on an old base version of Python (3.6) and do the final linking at install time. That still requires Xcode command line tools installed though. If anyone has an idea, please share.