我安装了 libpgm1.3。libpgm1.1 的文档在这里:http ://pythonhosted.org/libpgm/index.html (我找不到 1.3 的任何文档)。然后执行下面的代码。
import numpy
import libpgm
import libpgm.pgmlearner
控制台给了我一条错误消息。
File "test_libpgm.py", line 3, in <module>
import libpgm.pgmlearner
File "/usr/local/lib/python3.5/dist-packages/libpgm/pgmlearner.py", line 35
raise ImportError, "numpy is not installed on your system."
^
SyntaxError: invalid syntax
这意味着代码可以在第 1 行导入 numpy,但在第 3 行失败。我在这里检查了 pgmlearner.py:
32: try:
33: import numpy as np
34: except ImportError:
35: raise ImportError, "numpy is not installed on your system."
为什么不能导入 numpy?谁能解决这个问题?我在 Ubuntu 16.04 上使用 python 3.5。