【问题标题】:Read a list from stream using Yap-Prolog使用 Yap-Prolog 从流中读取列表
【发布时间】:2017-03-26 13:43:30
【问题描述】:

我想从我的 (yap) prolog 脚本中运行一个 (python3) 进程,并读取其格式化为整数列表的输出,例如[1,2,3,4,5,6]

这就是我的工作:

process_create(path(python3),
    ['my_script.py', MyParam],
    [stdout(pipe(Out))]),
read(Out, OutputList),
close(Out).

但是,它在 read/2 谓词处失败并出现错误:

PL_unify_term: PL_int64 not supported
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe

我确信我可以正确运行该过程,因为将[stdout(std)] 参数赋予process_create 程序会按预期输出[1,2,3,4,5,6]

奇怪的是,当我更改流程以输出一些常数项(如constant_term)时,它仍然给出相同的PL_int64 错误。向进程的输出 ([1,2,3,4,5,6].) 添加一个点并不能解决错误。使用 read_term/3 会出现同样的错误。 read_string/3 在 YAP-Prolog 中未定义。

我该如何解决这个问题?

【问题讨论】:

    标签: stream prolog pipe yap


    【解决方案1】:

    在 yap-users 邮件列表中询问后,我得到了the solution

    使用 libGMP 选项重新编译 YAP Prolog 6.2.2,现在它可以工作了。它也可能出现在 32 位 YAP 中。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多