0

我遇到了一个非常基本的问题,即 Owlready2 API get_topology() API 无法读取指向我的 owl 文件的 HTTPS URL 链接。对于 URLLIB API 有解决方案;但是,我不知道在 OwlReady2 API 的情况下如何处理它。

如果我使用基于“HTTP”的 URL(例如注释行),它可以正常工作。

import logging
from owlready2 import *


def main(argv):
    Logger()
    logger = logging.getLogger(__name__)

    #onto = get_ontology("http://www.lesfleursdunormal.fr/static/_downloads/pizza_onto.owl")
    onto.load()
    onto = get_ontology("https://github.com/anilj1/semanticallycorrect/blob/master/ontologies/country.owl")

if __name__ == '__main__':
    main(sys.argv[1:])

我得到的运行时错误是:

    except:  raise OwlReadyOntologyParsingError("Cannot download '%s'!" % f)
owlready2.base.OwlReadyOntologyParsingError: Cannot download 'https://github.com/anilj1/semanticallycorrect/blob/master/ontologies/country.owl'!

Process finished with exit code 1

主要调用跟踪如下。

Traceback (most recent call last):
  File "/Users/anjangam/workspace/python3venv/lib/python3.7/site-packages/owlready2/namespace.py", line 728, in load
    try:     fileobj = urllib.request.urlopen(f)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 222, in urlopen
    return opener.open(url, data, timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 525, in open
    response = self._open(req, data)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 543, in _open
    '_open', req)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 503, in _call_chain
    result = func(*args)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1360, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/urllib/request.py", line 1319, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1051)>
4

0 回答 0