ventolab / CellphoneDB

CellPhoneDB can be used to search for a particular ligand/receptor, or interrogate your own HUMAN single-cell transcriptomics data.
https://www.cellphonedb.org/
MIT License
305 stars 52 forks source link

error trying to download database #129

Closed kbrulois closed 7 months ago

kbrulois commented 11 months ago

Hello,

I'm trying to download the database using the tutorial:

https://github.com/ventolab/CellphoneDB/blob/master/notebooks/T00_DownloadDB.ipynb

Can you check if I'm running it correctly?

-- Version of the databse

cpdb_version = 'v4.1.0'

-- Path where the input files to generate the database are located

cpdb_target_dir = os.path.join('/Users/kbrulois/cpdb_tutorial/db', cpdb_version)

from cellphonedb.utils import db_utils

db_utils.download_database(cpdb_target_dir, cpdb_version)

Getting this error message:


SSLCertVerificationError Traceback (most recent call last) File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py:1348, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args) 1347 try: -> 1348 h.request(req.get_method(), req.selector, req.data, headers, 1349 encode_chunked=req.has_header('Transfer-encoding')) 1350 except OSError as err: # timeout error

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1286, in HTTPConnection.request(self, method, url, body, headers, encode_chunked) 1285 """Send a complete request to the server.""" -> 1286 self._send_request(method, url, body, headers, encode_chunked)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1332, in HTTPConnection._send_request(self, method, url, body, headers, encode_chunked) 1331 body = _encode(body, 'body') -> 1332 self.endheaders(body, encode_chunked=encode_chunked)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1281, in HTTPConnection.endheaders(self, message_body, encode_chunked) 1280 raise CannotSendHeader() -> 1281 self._send_output(message_body, encode_chunked=encode_chunked)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1041, in HTTPConnection._send_output(self, message_body, encode_chunked) 1040 del self._buffer[:] -> 1041 self.send(msg) 1043 if message_body is not None: 1044 1045 # create a consistent interface to message_body

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:979, in HTTPConnection.send(self, data) 978 if self.auto_open: --> 979 self.connect() 980 else:

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py:1458, in HTTPSConnection.connect(self) 1456 server_hostname = self.host -> 1458 self.sock = self._context.wrap_socket(self.sock, 1459 server_hostname=server_hostname)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py:517, in SSLContext.wrap_socket(self, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, session) 511 def wrap_socket(self, sock, server_side=False, 512 do_handshake_on_connect=True, 513 suppress_ragged_eofs=True, 514 server_hostname=None, session=None): 515 # SSLSocket class handles server_hostname encoding before it calls 516 # ctx._wrap_socket() --> 517 return self.sslsocket_class._create( 518 sock=sock, 519 server_side=server_side, 520 do_handshake_on_connect=do_handshake_on_connect, 521 suppress_ragged_eofs=suppress_ragged_eofs, 522 server_hostname=server_hostname, 523 context=self, 524 session=session 525 )

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py:1075, in SSLSocket._create(cls, sock, server_side, do_handshake_on_connect, suppress_ragged_eofs, server_hostname, context, session) 1074 raise ValueError("do_handshake_on_connect should not be specified for non-blocking sockets") -> 1075 self.do_handshake() 1076 except (OSError, ValueError):

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ssl.py:1346, in SSLSocket.do_handshake(self, block) 1345 self.settimeout(None) -> 1346 self._sslobj.do_handshake() 1347 finally:

SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)

During handling of the above exception, another exception occurred:

URLError Traceback (most recent call last) Cell In[6], line 3 1 from cellphonedb.utils import db_utils ----> 3 db_utils.download_database(cpdb_target_dir, cpdb_version)

File ~/cpdb/lib/python3.11/site-packages/cellphonedb/utils/db_utils.py:298, in download_database(target_dir, cpdb_version) 297 def download_database(target_dir, cpdb_version): --> 298 download_released_files(target_dir, cpdb_version, "cellphonedb.zip|_input|sources\/uniprot_synonyms")

File ~/cpdb/lib/python3.11/site-packages/cellphonedb/utils/db_utils.py:301, in download_released_files(target_dir, cpdb_version, regex) 300 def download_released_files(target_dir, cpdb_version, regex): --> 301 r = urllib.request.urlopen('https://github.com/ventolab/cellphonedb-data/archive/refs/tags/{}.zip'.format(cpdb_version) 302 zipContent = ZipFile(io.BytesIO(r.read())) 303 for fpath in zipContent.namelist():

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py:216, in urlopen(url, data, timeout, cafile, capath, cadefault, context) 214 else: 215 opener = _opener --> 216 return opener.open(url, data, timeout)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py:519, in OpenerDirector.open(self, fullurl, data, timeout) 516 req = meth(req) 518 sys.audit('urllib.Request', req.full_url, req.data, req.headers, req.get_method()) --> 519 response = self._open(req, data) 521 # post-process response 522 meth_name = protocol+"_response"

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py:536, in OpenerDirector._open(self, req, data) 533 return result 535 protocol = req.type --> 536 result = self._call_chain(self.handle_open, protocol, protocol + 537 '_open', req) 538 if result: 539 return result

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py:496, in OpenerDirector._call_chain(self, chain, kind, meth_name, args) 494 for handler in handlers: 495 func = getattr(handler, meth_name) --> 496 result = func(args) 497 if result is not None: 498 return result

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py:1391, in HTTPSHandler.https_open(self, req) 1390 def https_open(self, req): -> 1391 return self.do_open(http.client.HTTPSConnection, req, 1392 context=self._context, check_hostname=self._check_hostname)

File /Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/urllib/request.py:1351, in AbstractHTTPHandler.do_open(self, http_class, req, **http_conn_args) 1348 h.request(req.get_method(), req.selector, req.data, headers, 1349 encode_chunked=req.has_header('Transfer-encoding')) 1350 except OSError as err: # timeout error -> 1351 raise URLError(err) 1352 r = h.getresponse() 1353 except:

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1002)>

ktroule commented 11 months ago

Hi.

This issue doesn't seem to be related to CellPhoneDB but to the the SSL certificate. A possible solution could be to update it pip install --upgrade certifi.

Thanks