paper-qa
paper-qa copied to clipboard
SSL error for Semantic Scholar
Hi!
I'm using the command line tool, like pqa index or ask and always get an SSL error for semantic scholar:
ClientConnectorCertificateError: Cannot connect to host api.semanticscholar.org:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)')]
Is this problem on my side, with semantic scholar, or paper-qa? Or do I need an API key?
Cheers
Hey @Shellfishgene! 👋 I'm here to help you out with bugs, questions, and becoming a contributor. Let's squash those bugs together!
The SSL error you're encountering is likely related to your setup or the Semantic Scholar API. The paper-qa tool does not have specific SSL configurations, so the issue is probably due to the environment in which the tools are being run.
Here are some steps to resolve the SSL error:
- Update SSL Certificates: Ensure that your system's SSL certificates are up to date.
- Network Configuration: Verify that your network allows SSL connections to the Semantic Scholar API.
- Proxy Settings: If you are behind a proxy, ensure it is correctly configured to handle SSL traffic.
While an API key is optional, it is recommended to avoid rate limits. You can set the SEMANTIC_SCHOLAR_API_KEY environment variable to use an API key:
export SEMANTIC_SCHOLAR_API_KEY=your_semantic_scholar_api_key
However, the SSL error is not directly related to the presence or absence of an API key [1][2].
To continue talking to Dosu, mention @dosu.
@Shellfishgene I am not sure. To proceed, can you answer:
- Do you have the
SEMANTIC_SCHOLAR_API_KEYenvironment variable set? - Do you get the same outcome on different internet connections?
hi sorry to warm this up again – I am getting the same error; API Key is set and i get the same error on different internet connections. Should add that I didn't have the problem a few weeks ago.
Can you share your full stack? And is the error flaky, or does it always happen?
paper-qa = 5.0.5, python = 3.12, running on MacOS in a poetry venv – let me know if you need more details.
I used paper-qa intensively last month and didn't have the problem. Right now, the error is persistent. I'm getting this message (slightly abbreviated).
Retrying paperqa.clients.semantic_scholar._s2_get_with_retrying in 0.0 seconds as it raised ClientConnectorCertificateError: Cannot connect to host api.semanticscholar.org:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)')]. [...].
Traceback (most recent call last): File "/Users/daniel/Library/Caches/pypoetry/virtualenvs/rag-pipeline-bPftndy5-py3.12/lib/python3.12/site-packages/aiohttp/connector.py", line 1098, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs, sock=sock) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1146, in create_connection transport, protocol = await self._create_connection_transport( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/base_events.py", line 1179, in _create_connection_transport await waiter File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/sslproto.py", line 575, in _on_handshake_complete raise handshake_exc File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/asyncio/sslproto.py", line 557, in _do_handshake self._sslobj.do_handshake() File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/ssl.py", line 917, in do_handshake self._sslobj.do_handshake() ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1000)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/daniel/Library/Caches/pypoetry/virtualenvs/rag-pipeline-bPftndy5-py3.12/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 114, in call
result = await fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/daniel/Library/Caches/pypoetry/virtualenvs/rag-pipeline-bPftndy5-py3.12/lib/python3.12/site-packages/paperqa/clients/semantic_scholar.py", line 119, in _s2_get_with_retrying
return await _get_with_retrying(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/daniel/Library/Caches/pypoetry/virtualenvs/rag-pipeline-bPftndy5-py3.12/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 189, in async_wrapped
return await copy(fn, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/daniel/Library/Caches/pypoetry/virtualenvs/rag-pipeline-bPftndy5-py3.12/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 111, in call
do = await self.iter(retry_state=retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/daniel/Library/Caches/pypoetry/virtualenvs/rag-pipeline-bPftndy5-py3.12/lib/python3.12/site-packages/tenacity/asyncio/init.py", line 153, in iter
result = await action(retry_state)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/daniel/Library/Caches/pypoetry/virtualenvs/rag-pipeline-bPftndy5-py3.12/lib/python3.12/site-packages/tenacity/_utils.py", line 99, in inner
return call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/daniel/Library/Caches/pypoetry/virtualenvs/rag-pipeline-bPftndy5-py3.12/lib/python3.12/site-packages/tenacity/init.py", line 398, in
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/daniel/Documents/Research Projects/RAG/rag_pipeline/code/init_rag.py", line 102, in
turns out the simple fix is /Applications/Python\ 3.12/Install\ Certificates.command