NVIDIA / MinkowskiEngine

Minkowski Engine is an auto-diff neural network library for high-dimensional sparse tensors
https://nvidia.github.io/MinkowskiEngine
Other
2.47k stars 367 forks source link

cannot import name 'Sequence' from 'collections' #526

Open sajfb opened 1 year ago

sajfb commented 1 year ago

I just try to import MinkowskiEngine, but it has a major problem with its package dependency!

import numpy as np
import torch.nn as nn
import MinkowskiEngine as ME

This is the error that I get on torch.version : '1.13.1+cu117' and python 3.10.6

File ~/.local/lib/python3.10/site-packages/MinkowskiEngine/__init__.py:67
     51 from diagnostics import print_diagnostics
     53 from MinkowskiEngineBackend._C import (
     54     MinkowskiAlgorithm,
     55     CoordinateMapKey,
   (...)
     64     get_gpu_memory_info,
     65 )
---> 67 from MinkowskiKernelGenerator import (
     68     KernelRegion,
     69     KernelGenerator,
     70     convert_region_type,
     71     get_kernel_volume,
     72 )
     74 from MinkowskiTensor import (
     75     SparseTensorOperationMode,
     76     SparseTensorQuantizationMode,
   (...)
...
---> 26 from collections import Sequence, namedtuple
     27 from functools import reduce
     28 import numpy as np

ImportError: cannot import name 'Sequence' from 'collections' (/usr/lib/python3.10/collections/__init__.py)

This issue pertains to Python 3.10 which the collections package got changed. MinkowskiEngine requires some updates regarding to Python upgrades.

subminu commented 11 months ago

As this link, after python 3.10, Sequence has been moved to collections.abc not collections.

You can use MinkowskiEngine on Python 3.10 by editing the following files.

# You should edit the code that import Sequence as following code..
try: 
    from collections import Sequence
except ImportError:
    from collections.abc import Sequence