• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

4 library(janus): Call Python from Prolog
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog Python interface
        • library(janus): Call Python from Prolog
          • py_version/0
          • py_call/1
          • py_call/2
          • py_call/3
          • py_iter/2
          • py_iter/3
          • py_is_object/1
          • py_free/1
          • py_with_gil/1
          • py_func/3
          • py_func/4
          • py_dot/4
          • py_dot/5
          • values/3
          • keys/2
          • key/2
          • items/2
          • py_shell/0
          • py_pp/1
          • py_pp/2
          • py_pp/3
          • py_obj_dir/2
          • py_obj_dict/2
          • py_initialize/3
          • py_lib_dirs/1
          • py_add_lib_dir/1
          • py_add_lib_dir/2
          • Handling Python errors in Prolog
          • Janus and virtual environments (venv)
Availability::- use_module(library(janus)).(can be autoloaded)
Source[det]py_add_lib_dir(+Dir)
[det]py_add_lib_dir(+Dir, +Where)
Add a directory to the Python module search path. In the second form, Where is one of first or last. py_add_lib_dir/1 adds the directory as last.

Dir is in Prolog notation. The added directory is converted to an absolute path using the OS notation.

A flexible way to add the directory holding the current Prolog file to the Python search path is in the template below. The here/0 predicate can be replaced by any predicate defined in the file, either above or below the initializing/1 directive. A simple name like here/0 is good style when this code is part of a Prolog module.

here.
:- initialization
    (   source_file(here, File),
        file_directory_name(File, Dir),
        py_add_lib_dir(Dir, first)
    ).

ClioPatria (version V3.1.1-48-gf653ce4)