multitax icon indicating copy to clipboard operation
multitax copied to clipboard

urllib error

Open AlejandroSanchezCano opened this issue 1 year ago • 1 comments

Hello, I have used the multitax package before to mainly translate taxon ids to the taxon name (e.g. 3702 -> Arabidopsis thaliana). When I run code that previously was working, now I get the following error:

>>> from multitax import NcbiTx
>>> ncbi_tx = NcbiTx()
Traceback (most recent call last):
  File "/zfs/omics/personal/asanche2/miniconda3/envs/aa/lib/python3.10/urllib/request.py", line 1555, in ftp_open
    host = socket.gethostbyname(host)
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/zfs/omics/personal/asanche2/miniconda3/envs/aa/lib/python3.10/site-packages/multitax/ncbitx.py", line 15, in __init__
    super().__init__(**kwargs)
  File "/zfs/omics/personal/asanche2/miniconda3/envs/aa/lib/python3.10/site-packages/multitax/multitax.py", line 82, in __init__
    fhs = download_files(urls=urls if urls else self._default_urls,
  File "/zfs/omics/personal/asanche2/miniconda3/envs/aa/lib/python3.10/site-packages/multitax/utils.py", line 71, in download_files
    fileobj=load_url_mem(url), mode='r:gz')
  File "/zfs/omics/personal/asanche2/miniconda3/envs/aa/lib/python3.10/site-packages/multitax/utils.py", line 107, in load_url_mem
    urlstream = urllib.request.urlopen(url)
  File "/zfs/omics/personal/asanche2/miniconda3/envs/aa/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/zfs/omics/personal/asanche2/miniconda3/envs/aa/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/zfs/omics/personal/asanche2/miniconda3/envs/aa/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/zfs/omics/personal/asanche2/miniconda3/envs/aa/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/zfs/omics/personal/asanche2/miniconda3/envs/aa/lib/python3.10/urllib/request.py", line 1557, in ftp_open
    raise URLError(msg)
urllib.error.URLError: <urlopen error [Errno -2] Name or service not known>

AlejandroSanchezCano avatar Mar 30 '24 14:03 AlejandroSanchezCano

I just run the same command here and it works fine.

ncbi_tx = NcbiTx() downloads the NCBI taxdump file and my guess is that you probably had some network issues at the time.

Alternatively you can always use local files downloaded independently ncbi_tx = NcbiTx(files='taxdump.tar.gz') or an alternative url (http instead of default ftp) ncbi_tx = NcbiTx(urls='http://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz')

pirovc avatar Apr 04 '24 10:04 pirovc