-
Notifications
You must be signed in to change notification settings - Fork 122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails to execute a query on dbpedia: ssl certificate problem #168
Comments
Hi, I have encountered the same issue. Best regards |
I have been successfully using myBinder to run a notebook containing SPARQLWrapper code for a few weeks. Towards the end of last week it suddenly stopped working. In trying to get to the bottom of the issue I've found the following error
Is this the same issue or is something else going on? |
There is also #102 which seems to be related. |
Hi @AlasdairGray , |
You can fire up this notebook on myBinder, run all the cells then select the first query from the dropdown list of available queries 'Number of Triples', and click Execute. This throws the exception (not sure why the exception text is not displaying in the UI). You can find the exception text below in the generated log file
The query runs fine when I run it directly through the GraphDB interface, and worked fine up until last week through the notebook. Only change in the notebook is the tweak I made today to the logging so that we can see the error message. Nothing has changed on the server side as far as I'm aware. |
The corresponding curl command works fine
|
For me the following snippet works fine: from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("https://swel.macs.hw.ac.uk/data/repositories/bioschemas")
sparql.setQuery("""
SELECT * WHERE {
?s a ?o.
}
LIMIT 10
""")
sparql.setReturnFormat(JSON)
ret = sparql.queryAndConvert()
for r in ret["results"]["bindings"]:
print(r) |
It seems that things work fine on a Windows machine but not on a Mac (I've been discussing the issue with a colleague), not sure about Linux. We've put in a workaround, but suspect that the underlying cause could be to do with the certificate on the server. |
@sven-h Your snippet works well. I tried: sparql = SPARQLWrapper("http://dbpedia.org/sparql")
sparql.setQuery("SELECT DISTINCT ?geometry WHERE {<http://dbpedia.org/resource/Paris> geo:geometry ?geometry}")
sparql.setReturnFormat(JSON)
results = sparql.query().convert() It works with Python 3.7, but the reported SSL exception is raised using Python 3.8 (also 3.10) on my Windows machine. |
Hi, your script works fine for me:
Can you check the folder of openssl with |
Hi sven-h, I used virtualenv instead of conda. An openssl binary is not available there. I tried adding pyOpenSSL, but it did not help. I noticed that sparqlwrapper works fine with Python 3.7.3. But with Python 3.7.4 and higher, the error appears. A workaround, mentioned on stackoverflow, is to add the following lines before the query:
Do you have a more elegant solution? |
Hello
I'm used to use SPARQLWrapper with success.
But, today, in my environment, I get the following error
Début de run
Comment :=>> <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)>
and I don't understand how tosolve this problem.
If I directly use urlopen, I can do something like this (unsecure, I know)
unsecurecontext = ssl._create_unverified_context()
... urlopen(urldbpedia, context=unsecurecontext) ...
But, I'm unable to find a method to manage that with SPARQLWrapper, cleanly or uncleanly.
(I know about issue #56, but I doesn't see a solution which apply)
ps: my environment is a virtual lab in a moodle platform
The text was updated successfully, but these errors were encountered: