Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sajfb opened this issue Feb 28, 2023 · 1 comment
Open

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

sajfb opened this issue Feb 28, 2023 · 1 comment

Comments

@sajfb
Copy link

sajfb commented Feb 28, 2023

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
Copy link

subminu commented Dec 14, 2023

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.

  • MinkowskiEngine/utils/quantization.py
  • MinkowskiEngine/MinkowskiCommon.py
  • MinkowskiEngine/MinkowskiCoordinateManager.py
  • MinkowskiEngine/MinkowskiKernelGenerator.py
  • MinkowskiEngine/MinkowskiTensorField.py
# You should edit the code that import Sequence as following code..
try: 
    from collections import Sequence
except ImportError:
    from collections.abc import Sequence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants