beetbox / beets

music library manager and MusicBrainz tagger
http://beets.io/
MIT License
12.57k stars 1.8k forks source link

Error when loading `convert` plugin #5324

Closed seadowg closed 5 days ago

seadowg commented 1 week ago

Problem

Running beet (any command) fails to load the convert plugin:

** error loading plugin convert:
Traceback (most recent call last):
  File "/usr/share/beets/beets/plugins.py", line 268, in load_plugins
    namespace = __import__(modname, None, None)
  File "/home/beets/.local/lib/python3.10/site-packages/beetsplug/convert.py", line 32, in <module>
    from beets.util.m3u import M3UFile
ModuleNotFoundError: No module named 'beets.util.m3u'

Setup

I'm running in a Docker image built from the following file:

FROM ubuntu:jammy

RUN adduser beets
RUN apt-get update && apt-get install -y beets ffmpeg
RUN apt-get update && apt-get install -y wget unzip
COPY beets-config.yaml /home/beets/.config/beets/config.yaml

USER beets
RUN pip install --user beets-extrafiles

WORKDIR /home/beets

The output of beet version is:

beets version 1.6.0
Python version 3.10.12
plugins: extrafiles

My configuration (output of beet config) is:

directory: /home/beets/music
library: /home/beets/music/beet-library.db

plugins: convert extrafiles
asciify_paths: yes

format_item: $artist - $album - $title ($format $bitrate $samplerate $bitdepth)
convert:
    copy_album_art: yes
    never_convert_lossy_files: yes
    formats:
        cd:
            command: ffmpeg -i $source -y -vn -sample_fmt s16 -ar 44100 $dest
            extension: flac
        cd_with_dither:
            command: ffmpeg -i $source -y -vn -sample_fmt s16 -ar 44100 -dither_method triangular $dest
            extension: flac
extrafiles:
    patterns:
        jpg: '*.jpg'
        pdf: '*.pdf'
        png: '*.png'

    paths: {}
bal-e commented 5 days ago

It looks like you have beets installed both system-wide (using the Ubuntu beets package) and in your user-local Pip folder. The system-wide version is quite old (1.6.0 was released in Nov 2021) and is missing the beets.util.m3u module. I suggest not installing beets from the Ubuntu package and instead relying on pip install --user beets. You could also use a faster-moving Linux distribution.

bal-e commented 5 days ago

We can also strive to provide nicer errors here, by having each plugin check the running beets version to ensure compatibility. That way, you would get a slightly nicer error (something along the lines of "the convert plugin requires beets version 2.0.0 or newer") that could point you in the right direction. This would add a bit of boilerplate to every plugin module, but could be worth it in the end. I'll wait for input from an official maintainer.

seadowg commented 5 days ago

It looks like you have beets installed both system-wide (using the Ubuntu beets package) and in your user-local Pip folder.

I'm confused to how that's the case. Does pip install --user beets-extrafiles end up install beets as it's a dependency or something?

seadowg commented 5 days ago

I've updated my Dockerfile as suggested and everything works. Here's new one for anyone else who runs into the same problem:

FROM ubuntu:jammy

RUN apt-get update && apt-get install -y python3 python3-pip ffmpeg

RUN adduser beets
USER beets
RUN pip install --user beets
RUN pip install --user beets-extrafiles
COPY beets-config.yaml /home/beets/.config/beets/config.yaml

ENV PATH="$PATH:~/.local/bin/"
WORKDIR /home/beets

I had to modify the path to include the pip installed binaries, but I'm guessing that's expected.

bal-e commented 5 days ago

Does pip install --user beets-extrafiles end up install beets as it's a dependency or something?

It looks like it -- and pip was installing a much newer version of beets, resulting in the incompatibilities (although beets-extrafiles itself may also depend on a more recent version of beets than Ubuntu provides). I think your updated Dockerfile comprehensively solves this problem -- if you're satisfied, please close the issue.