I am trying to use one package that somebody developed on GitHub called PyLipid. The first parts of the code are importing various packages, but I am continuously getting this error, showed bellow:
%matplotlib inline
import pylipid
import collections
from pylipid.api import LipidInteraction
# print(pylipid.__version__) # make sure pylipid version is later than 1.4
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Input In [37], in <cell line: 4>()
2 import pylipid
3 import collections
----> 4 from pylipid.api import LipidInteraction
File ~/miniconda3/envs/work/lib/python3.10/site-packages/pylipid/api/__init__.py:32, in <module>
1 ##############################################################################
2 # PyLipID: A python module for analysing protein-lipid interactions
3 #
(...)
14 # copies or substantial portions of the Software.
15 ##############################################################################
17 r"""
18 PyLipID class
19 =============
(...)
29
30 """
---> 32 from .api import LipidInteraction
File ~/miniconda3/envs/work/lib/python3.10/site-packages/pylipid/api/api.py:30, in <module>
28 import pandas as pd
29 from tqdm import trange, tqdm
---> 30 from p_tqdm import p_map
31 from ..func import cal_contact_residues
32 from ..func import Duration
File ~/miniconda3/envs/work/lib/python3.10/site-packages/p_tqdm/__init__.py:1, in <module>
----> 1 from p_tqdm.p_tqdm import p_map, p_imap, p_umap, p_uimap, t_map, t_imap
3 __all__ = [
4 'p_map',
5 'p_imap',
(...)
9 't_imap'
10 ]
File ~/miniconda3/envs/work/lib/python3.10/site-packages/p_tqdm/p_tqdm.py:11, in <module>
1 """Map functions with tqdm progress bars for parallel and sequential processing.
2
3 p_map: Performs a parallel ordered map.
(...)
8 t_imap: Returns an iterator for a sequential map.
9 """
---> 11 from collections import Sized
12 from typing import Any, Callable, Generator, Iterable, List
14 from pathos.helpers import cpu_count
ImportError: cannot import name 'Sized' from 'collections' (/home/srdjanm/miniconda3/envs/work/lib/python3.10/collections/__init__.py)
Does anybody know how to solve this error? I have also posted the question on the webpage in github but it might take a while for someone to respond, also this seems to me like a more general problem. Is this the package or "python version" related issue?
CodePudding user response:
You may want to modify one line in the library to it works. It was created a pull request in github of p_tqdm library
In file ~/miniconda3/envs/work/lib/python3.10/site-packages/p_tqdm/p_tqdm.py
modify line 11
from
from collections import Sized
to
from collections.abc import Sized