urinieto / msaf

Music Structure Analysis Framework
MIT License
501 stars 79 forks source link

ImportError: cannot import name 'inf' from 'scipy' #161

Closed tanders closed 3 months ago

tanders commented 3 months ago

Thanks for MSAF!

When importing this library (with python3.10 and a recent scipy version, seemingly 1.14.0), I ran into the following error:

>>> import msaf
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/dist-packages/msaf/__init__.py", line 25, in <module>
    from . import algorithms
  File "/usr/local/lib/python3.10/dist-packages/msaf/algorithms/__init__.py", line 23, in <module>
    [importlib.import_module(module_name) for module_name in module_names]
  File "/usr/local/lib/python3.10/dist-packages/msaf/algorithms/__init__.py", line 23, in <listcomp>
    [importlib.import_module(module_name) for module_name in module_names]
  File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/usr/local/lib/python3.10/dist-packages/msaf/algorithms/cnmf/__init__.py", line 10, in <module>
    from .segmenter import *
  File "/usr/local/lib/python3.10/dist-packages/msaf/algorithms/cnmf/segmenter.py", line 7, in <module>
    from msaf import pymf
  File "/usr/local/lib/python3.10/dist-packages/msaf/pymf/__init__.py", line 39, in <module>
    from .sivm_sgreedy import *
  File "/usr/local/lib/python3.10/dist-packages/msaf/pymf/sivm_sgreedy.py", line 22, in <module>
    from .sivm_search import SIVM_SEARCH
  File "/usr/local/lib/python3.10/dist-packages/msaf/pymf/sivm_search.py", line 20, in <module>
    from scipy import inf
ImportError: cannot import name 'inf' from 'scipy' (/usr/local/lib/python3.10/dist-packages/scipy/__init__.py)

I checked your source file msaf/pymf/sivm_search.py, at it appears the imported inf is not used anyway in that file. So, simply removing that import statement might already fix this problem.

All the best, Torsten

urinieto commented 3 months ago

Thanks for reporting this. Would you mind creating a PR for this? :)

tanders commented 3 months ago

Thanks for coming back. Will do.

tanders commented 3 months ago

Turns out, this (and other) unused scipy imports are already fixed in the current main branch. I had imported MSAF with pip using the last release, and that still contains the problem. So, I will simply use the latest main branch instead.

Again, thanks for all your work you put into this!

urinieto commented 3 months ago

Oh, I forgot about it! Thanks for looking into it, and glad to know it's all fixed on main. I should upgrade the pip version soon. Thanks for your kind words :)

ruohoruotsi commented 3 months ago

+100 on msaf and the work you've put into it 👏 👏 . I would also love if you cut a tag/new-release to grab the latest changes since msaf 0.1.80 🚀