无法从 libpgm 包中读取文件

问题描述

我为我的 jupyter 笔记本安装了 libpgm

pip 安装 libpgm

然后按如下方式运行几次导入

import sys
import json
import libpgm
from libpgm.nodedata import NodeData
from libpgm.graphskeleton import GraphSkeleton
from libpgm.hybayesiannetwork import HyBayesianNetwork

我有一个错误

Traceback (most recent call last):

  File "C:\Users\19413\conda\lib\site-packages\IPython\core\interactiveshell.py",line 3343,in run_code
    exec(code_obj,self.user_global_ns,self.user_ns)

  File "<ipython-input-7-80536a116c64>",line 4,in <module>
    from libpgm.nodedata import NodeData

  File "C:\Users\19413\conda\lib\site-packages\libpgm\nodedata.py",line 91
    print "Error: NodeData did not recognize input file format."
          ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Error: NodeData did not recognize input file format.")?

有谁知道是什么导致了错误?

非常感谢您的帮助

解决方法

好吧,错误报告的最后一行准确地说明了导致错误的原因:

Missing parentheses in call to 'print'. Did you mean print("Error: NodeData did not recognize input file format.")?

与 Python 2 不同,Python 3 要求将所有打印语句括在括号中。我不熟悉 libpgm 库,但在我看来这 has been fixed five years ago。请确保您使用此库的最新版本或使用 Python 2 运行您的代码。

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...