CPJKU / madmom

Python audio and music signal processing library
https://madmom.readthedocs.io
Other
1.35k stars 206 forks source link

ImportError: cannot import name 'MutableSequence' from 'collections' #535

Open Winter-Sno opened 10 months ago

Winter-Sno commented 10 months ago

Expected behaviour

I want to do onset detection in a classical music piece. I expect the program to return an arraylist like [1,2,3,4,...] marking the onset timestamp of each note.

Actual behaviour

The program did nothing and an error like this occurred. (╥﹏╥...)

Traceback (most recent call last):
  File "D:\workspace\SRT_simulation\madmom_note_extract.py", line 1, in <module>
    import madmom
  File "D:\anaconda3\Lib\site-packages\madmom\__init__.py", line 24, in <module>
    from . import audio, evaluation, features, io, ml, models, processors, utils
  File "D:\anaconda3\Lib\site-packages\madmom\audio\__init__.py", line 27, in <module>
    from . import comb_filters, filters, signal, spectrogram, stft
  File "madmom\\audio\\comb_filters.pyx", line 15, in init madmom.audio.comb_filters
  File "D:\anaconda3\Lib\site-packages\madmom\processors.py", line 23, in <module>
    from collections import MutableSequence
ImportError: cannot import name 'MutableSequence' from 'collections' (D:\anaconda3\Lib\collections\__init__.py)

Steps needed to reproduce the behaviour

import madmom

filename = '01.Overture.flac'

def madmom_get_note_map(filename):
    proc = madmom.features.onsets.CNNOnsetProcessor()
    proc(filename)

if __name__ == '__main__':
    madmom_get_note_map(filename)

Information about installed software

python 3.11 (using anaconda)
madmom 0.16.1
numpy 1.24.3
scipy 1.11.1
cython 3.0.8
mido 1.3.2
packaging 23.1
lucala commented 10 months ago

I had the same issue. The problem is with the python version we're using. As mentioned in this stackoverflow post the MutableSequence is now in collections.abc.

Changing line 23 in your D:\anaconda3\Lib\site-packages\madmom\processors.py file to from collections.abc import MutableSequence solves the issue.

codeknowhow commented 9 months ago

If you're on a mac the path is:

~/anaconda3/lib/python3.11/site-packages/madmom/processors.py

Just add the same change that @lucala provided above

mgazier commented 4 months ago

i had issues with Madmom + python 3.11 and a few items like collections. i added some code to fix a few settings without having to touch the source code. https://github.com/mgazier/madmom_python311

Centauria commented 3 months ago

It is a python version issue. madmom will trigger this error when working on Python version >= 3.10 hope for fixing