Skip to content

ImportError: cannot import name 'T_co' from 'torch.utils.data.dataset' #1

@mmich-pl

Description

@mmich-pl

Hi, I tired to use this package and it looks like there was some change in torch that breaks herference.

I used suggested way of instalation:

python3 -m pip install .

And from what I can see torch-2.5.1 was used to build herference.

Here is the log of the error after use of reference in program:

.venv/lib/python3.12/site-packages/transformers/utils/generic.py:441: FutureWarning: `torch.utils._pytree._register_pytree_node` is deprecated. Please use `torch.utils._pytree.register_pytree_node` instead.
  _torch_pytree._register_pytree_node(
Traceback (most recent call last):
  File "coreference/main.py", line 2, in <module>
    from src.resolver import Resolver
  File "coreference/src/resolver.py", line 13, in <module>
    import herference
  File ".venv/lib/python3.12/site-packages/herference/__init__.py", line 5, in <module>
    from herference.manager import Herference
  File ".venv/lib/python3.12/site-packages/herference/manager.py", line 19, in <module>
    from herference.batch import CorefLoader
  File ".venv/lib/python3.12/site-packages/herference/batch.py", line 10, in <module>
    from herference.dataset import CorefDataset
  File ".venv/lib/python3.12/site-packages/herference/dataset.py", line 12, in <module>
    from torch.utils.data.dataset import T_co
ImportError: cannot import name 'T_co' from 'torch.utils.data.dataset' (.venv/lib/python3.12/site-packages/torch/utils/data/dataset.py). Did you mean: '_T_co'?

As a quickfix I downloaded your project and changed T_co but my knowleadge about torch is to brief to debug if it break something (code is working though). Maybe you should consider changing this line torch = ">=2.0.0, !=2.0.1, !=2.1.0" from pyptoject.toml. to define concrete version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions