[Python] Why is Hello Magenta Colab failing with 'metadata-generation-failed' error?

Discussão em 'Python' iniciado por Stack, Maio 15, 2025.

  1. Stack

    Stack Membro Participativo

    I'm currently trying out to use the Magenta (music generation) library using python, starting from the official 'Hello Magenta' colab notebook (https://colab.research.google.com/notebooks/magenta/hello_magenta/hello_magenta.ipynb). However, the colab notebook fails on the setup stage with metadata generation failed error.

    This is the first block of code to be executed.

    print('Installing dependencies...')
    !apt-get update -qq && apt-get install -qq libfluidsynth2 fluid-soundfont-gm build-essential libasound2-dev libjack-dev
    !pip install -qU pyfluidsynth pretty_midi

    !pip install -qU magenta

    # Hack to allow python to pick up the newly-installed fluidsynth lib.
    # This is only needed for the hosted Colab environment.
    import ctypes.util
    orig_ctypes_util_find_library = ctypes.util.find_library
    def proxy_find_library(lib):
    if lib == 'fluidsynth':
    return 'libfluidsynth.so.1'
    else:
    return orig_ctypes_util_find_library(lib)
    ctypes.util.find_library = proxy_find_library

    print('Importing libraries and defining some helper functions...')
    from google.colab import files

    import magenta
    import note_seq
    import tensorflow

    print(' Done!')
    print(magenta.__version__)
    print(tensorflow.__version__)


    And this is the printed result of the block above.

    Installing dependencies...
    W: Skipping acquire of configured file 'main/source/Sources' as repository 'https://r2u.stat.illinois.edu/ubuntu jammy InRelease' does not seem to provide it (sources.list entry misspelt?)
    E: Package 'libfluidsynth2' has no installation candidate
    Preparing metadata (setup.py) ... done
    Preparing metadata (setup.py) ... done
    Preparing metadata (setup.py) ... done
    Preparing metadata (setup.py) ... done
    error: subprocess-exited-with-error

    × python setup.py egg_info did not run successfully.
    │ exit code: 1
    ╰─> See above for output.

    note: This error originates from a subprocess, and is likely not a problem with pip.
    Preparing metadata (setup.py) ... error
    error: metadata-generation-failed

    × Encountered error while generating package metadata.
    ╰─> See above for output.

    note: This is an issue with the package mentioned above, not pip.
    hint: See above for details.
    Importing libraries and defining some helper functions...


    I searched about this kind of problems and I think it is likely that the colab notebook is too old and deprecated to be used on the default installations on colab nowadays. So I tried starting off with pip upgrade, but this gets the colab session restarted because of certain libraries being imported multiple times and does not help much. What should I fix to use run these code properly?

    Continue reading...

Compartilhe esta Página