使用 Yap-Prolog 从流中读取列表
Read a list from stream using Yap-Prolog
我想从我的 (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
我确信我可以 运行 正确地处理这个过程,因为给 process_create
的 [stdout(std)]
参数可以让程序按预期输出 [1,2,3,4,5,6]
。
奇怪的是,当我更改过程以输出一些常数项(如 constant_term
)时,它仍然给出相同的 PL_int64
错误。在过程的输出 ([1,2,3,4,5,6].
) 上附加一个点并不能解决错误。使用 read_term/3
会产生相同的错误。 read_string/3
在 YAP-Prolog 中未定义。
我该如何解决这个问题?
在 yap-users 邮件列表询问后,我得到了 the solution。
使用 libGMP 选项重新编译了 YAP Prolog 6.2.2,现在它可以工作了。它也可能出现在 32 位 YAP 中。
我想从我的 (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
我确信我可以 运行 正确地处理这个过程,因为给 process_create
的 [stdout(std)]
参数可以让程序按预期输出 [1,2,3,4,5,6]
。
奇怪的是,当我更改过程以输出一些常数项(如 constant_term
)时,它仍然给出相同的 PL_int64
错误。在过程的输出 ([1,2,3,4,5,6].
) 上附加一个点并不能解决错误。使用 read_term/3
会产生相同的错误。 read_string/3
在 YAP-Prolog 中未定义。
我该如何解决这个问题?
在 yap-users 邮件列表询问后,我得到了 the solution。
使用 libGMP 选项重新编译了 YAP Prolog 6.2.2,现在它可以工作了。它也可能出现在 32 位 YAP 中。