我是Python初学者。我正在使用owlready研究本体。我已在 PyCharm IDE 上安装了 owlready 库,但在 python 代码中导入 owlready 时出现问题。我已经尝试过 from owlready import *
就像文档中一样,但它总是给我:
Traceback (most recent call last):
File "C:/Users/siekoo/OneDrive/Development/python/NER/onto_start.py", line 1, in <module>
from owlready import *
File "C:\winpython\python-2.7.10.amd64\lib\site-packages\owlready\__init__.py", line 85
def __init__(self, *Entities, ontology = None):
^
SyntaxError: invalid syntax
最佳答案
看起来 Owlready 适用于 Python 3,而您使用的是 Python 2。请更改您的 Python 版本以使其正常工作。
无效语法错误是由于新的 Python 3 参数列表造成的,请参阅:https://docs.python.org/3/tutorial/controlflow.html#arbitrary-argument-lists
关于python - 无法将 Owlready 库导入 Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39719119/