lambdamusic / Ontospy

Python library and command-line interface for inspecting and visualizing RDF models aka ontologies.
http://lambdamusic.github.io/Ontospy/
MIT License
218 stars 52 forks source link

Error with opening a sparql endpoint #55

Closed lambdamusic closed 2 years ago

lambdamusic commented 5 years ago

The error seems to be caused by rdflib - see https://github.com/RDFLib/rdflib/issues/889

$ python -m ontospy.tests.test_sparql
-------------------
Ontospy  v1.9.7
-------------------
=================
TEST: Loading <http://dbpedia.org/sparql> endpoint.
=================
Error trying to connect to Endpoint.
E
======================================================================
ERROR: test1_load_dbpedia (__main__.TestSparqlStore)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/michele.pasin/Dropbox/code/python/ontospy/ontospyProject/ontospy/tests/test_sparql.py", line 38, in test1_load_dbpedia
    o = Ontospy(sparql_endpoint=self.ENDPOINT, verbose=True)
  File "/Users/michele.pasin/Dropbox/code/python/ontospy/ontospyProject/ontospy/core/ontospy.py", line 91, in __init__
    self.load_sparql(sparql_endpoint, verbose, hide_base_schemas, credentials)
  File "/Users/michele.pasin/Dropbox/code/python/ontospy/ontospyProject/ontospy/core/ontospy.py", line 126, in load_sparql
    graph = rdflib.Graph('SPARQLStore')
  File "/Users/michele.pasin/Envs/ontospy_py3/lib/python3.7/site-packages/rdflib/graph.py", line 313, in __init__
    self.__store = store = plugin.get(store, Store)()
  File "/Users/michele.pasin/Envs/ontospy_py3/lib/python3.7/site-packages/rdflib/plugins/stores/sparqlstore.py", line 232, in __init__
    self.setUseKeepAlive()
  File "/Users/michele.pasin/Envs/ontospy_py3/lib/python3.7/site-packages/SPARQLWrapper/Wrapper.py", line 587, in setUseKeepAlive
    if urllib2._opener and any(isinstance(h, HTTPHandler) for h in urllib2._opener.handlers):
NameError: name 'urllib2' is not defined

----------------------------------------------------------------------
Ran 1 test in 0.065s

FAILED (errors=1)
CrypticGuy commented 2 years ago

This issue seems to be fixed in the latest versions. Should be closed.

Ontospy v1.9.9.4
-------------------

=================

TEST SPARQL: Loading data from remote endpoint.

=================

=================
TEST: Querying <http://dbpedia.org/sparql> endpoint...
=================
<Ontospy Graph (sparql endpoint = <http://dbpedia.org/sparql>)>
---------
(rdflib.term.URIRef('http://www.openlinksw.com/schemas/virtrdf#QuadMapFormat'),)
(rdflib.term.URIRef('http://www.openlinksw.com/schemas/virtrdf#QuadStorage'),)
(rdflib.term.URIRef('http://www.openlinksw.com/schemas/virtrdf#array-of-QuadMapFormat'),)
(rdflib.term.URIRef('http://www.openlinksw.com/schemas/virtrdf#QuadMap'),)
(rdflib.term.URIRef('http://www.openlinksw.com/schemas/virtrdf#QuadMapValue'),)
(rdflib.term.URIRef('http://www.openlinksw.com/schemas/virtrdf#array-of-QuadMapColumn'),)
(rdflib.term.URIRef('http://www.openlinksw.com/schemas/virtrdf#QuadMapColumn'),)
(rdflib.term.URIRef('http://www.openlinksw.com/schemas/virtrdf#array-of-QuadMapATable'),)
(rdflib.term.URIRef('http://www.openlinksw.com/schemas/virtrdf#QuadMapATable'),)
(rdflib.term.URIRef('http://www.openlinksw.com/schemas/virtrdf#QuadMapFText'),)
.
----------------------------------------------------------------------
Ran 1 test in 1.686s

OK
lambdamusic commented 2 years ago

Definitely working on latest release https://github.com/lambdamusic/Ontospy/releases/tag/2.0.0-alpha