pyg-team / pytorch_geometric

Graph Neural Network Library for PyTorch
https://pyg.org
MIT License
21k stars 3.62k forks source link

Import Error #1526

Closed hyqyoung closed 4 years ago

hyqyoung commented 4 years ago

❓ Questions & Help

from torchgeometric.utils import scatter Traceback (most recent call last): File "", line 1, in ImportError: cannot import name 'scatter_'

And I find it that there is no scatter_.py under python3.6/site-packages/torch_geometric/utils

rusty1s commented 4 years ago

The scatter_ call got removed in one of the more recent versions, and you can now simply use torch.scatter(..., reduce='add') for the same effect.

hyqyoung commented 4 years ago

The scatter_ call got removed in one of the more recent versions, and you can now simply use torch.scatter(..., reduce='add') for the same effect.

Yes, I find the reason is using "pip install torch-geometric" will download the latest version of torch-geometric which is 1.6.1, but the method "torchgeometric.utils.scatter" only exists before version 1.4.3 or earlier. So I just update version 1.4.3 and it works.

Shakib-IO commented 1 year ago

from torch_geometric.utils import accuracy

cannot import name 'accuracy' from 'torch_geometric.utils' (/usr/local/lib/python3.7/dist-packages/torch_geometric/utils/__init__.py)
rusty1s commented 1 year ago

We dropped support for our metric package and moved to torchmetrics. Where do you see this issue?

AlanLeAI commented 5 months ago

I got the issue of ImportError: cannot import name 'index_sort' from 'torch_geometric.utils' (/Users/tuanle/miniforge3/envs/torch-gpu/lib/python3.8/site-packages/torch_geometric/utils/init.py)

When importing 'import torch_geometric', may I ask If someone can help me out?

I use

pytorch 2.1.0 py3.8_0 pytorch pytorch-metric-learning 2.5.0 pypi_0 pypi torch 2.1.0 pypi_0 pypi torch-cluster 1.6.3 pypi_0 pypi torch-geometric 2.5.2 pypi_0 pypi torch-points-kernels 0.6.10 pypi_0 pypi torch-scatter 2.1.2 pypi_0 pypi torch-sparse 0.6.18 pypi_0 pypi torch-spline-conv 1.2.2 pypi_0 pypi torchaudio 2.1.0 py38_cpu pytorch torchdata 0.6.1 pypi_0 pypi torchmetrics 1.2.0 pypi_0 pypi torchnet 0.0.4 pypi_0 pypi torchtext 0.15.2 pypi_0 pypi torchvision 0.16.0 pypi_0 pypi

rusty1s commented 5 months ago

It got moved to

torch_geometric.utils._index_sort

At best, import via


from torch_geometric.utils import index_sort