0

I am trying to install pytrec_eval package using this command python -m pip install pytrec_eval but it fails with the following error: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1133). I am trying to install it in a conda environment with python=3.9 on a Linux machine (Ubuntu 9.4.0).

Here is the log of the error:

Collecting pytrec_eval
  Using cached pytrec_eval-0.5.tar.gz (15 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'error'
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [44 lines of output]
      Traceback (most recent call last):
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/urllib/request.py", line 1346, in do_open
          h.request(req.get_method(), req.selector, req.data, headers,
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/http/client.py", line 1285, in request
          self._send_request(method, url, body, headers, encode_chunked)
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/http/client.py", line 1331, in _send_request
          self.endheaders(body, encode_chunked=encode_chunked)
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/http/client.py", line 1280, in endheaders
          self._send_output(message_body, encode_chunked=encode_chunked)
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/http/client.py", line 1040, in _send_output
          self.send(msg)
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/http/client.py", line 980, in send
          self.connect()
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/http/client.py", line 1454, in connect
          self.sock = self._context.wrap_socket(self.sock,
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/ssl.py", line 501, in wrap_socket
          return self.sslsocket_class._create(
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/ssl.py", line 1074, in _create
          self.do_handshake()
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/ssl.py", line 1343, in do_handshake
          self._sslobj.do_handshake()
      ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1133)
      
      During handling of the above exception, another exception occurred:
      
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-d8_09f0p/pytrec-eval_ea7e63f86646420cbfc12ae9c46aac88/setup.py", line 27, in <module>
          response = urllib.request.urlopen(REMOTE_TREC_EVAL_URI)
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/urllib/request.py", line 214, in urlopen
          return opener.open(url, data, timeout)
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/urllib/request.py", line 517, in open
          response = self._open(req, data)
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/urllib/request.py", line 534, in _open
          result = self._call_chain(self.handle_open, protocol, protocol +
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/urllib/request.py", line 494, in _call_chain
          result = func(*args)
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/urllib/request.py", line 1389, in https_open
          return self.do_open(http.client.HTTPSConnection, req,
        File "/home/myusername/miniconda3/envs/hipporag-py39/lib/python3.9/urllib/request.py", line 1349, in do_open
          raise URLError(err)
      urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1133)>
      Fetching trec_eval from https://github.com/usnistgov/trec_eval/archive/v9.0.8.tar.gz.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I am only getting the error with this package, not the remaining ones.

2
  • pytrec_eval is a Python interface to trec_eval. When it's being installed pytrec_eval downloads trec_eval from an URL written in its setup.py. You seem to have an HTTPS (SSL) problem with this URL. If you're at home — ask you provider. If you're in an enterprise — ask you admins. See stackoverflow.com/… Commented Jul 3, 2024 at 12:13
  • @phd: indeed, I am in a company network. I ended up working it around to install it. Commented Jul 3, 2024 at 14:13

1 Answer 1

0

This is a workaround to install the package but does not solve the SSL certificate error problem.

I downloaded the pytrec_eval code from github and navigated to the project directory:

git clone https://github.com/cvangysel/pytrec_eval.git
cd pytrec_eval

Then, I downloaded trec_eval where pytrec_eval setup.py file fails to connect to:

grep https://github.com/usnistgov/trec_eval/archive/v9.0.8.tar.gz

I extracted the zip file to trec_eval directory:

tar -xvzf v9.0.8.tar.gz -C trec_eval

And finally, I ran the setup.py with the install option:

python setup.py install
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.