FIX munkres library Syntax error on a python 2 only machine

Problem

I’ve installed beets in a Docker image that’s based on debian:buster with only python 2 installed. Running beets yields this error message:

$ beet 

Led to this problem:

Traceback (most recent call last):
  File "/usr/local/bin/beet", line 6, in <module>
    from beets.ui import main
  File "/usr/local/lib/python2.7/dist-packages/beets/ui/__init__.py", line 42, in <module>
    from beets.autotag import mb
  File "/usr/local/lib/python2.7/dist-packages/beets/autotag/__init__.py", line 26, in <module>
    from .match import tag_item, tag_album, Proposal  # noqa
  File "/usr/local/lib/python2.7/dist-packages/beets/autotag/match.py", line 24, in <module>
    from munkres import Munkres
  File "/usr/local/lib/python2.7/dist-packages/munkres.py", line 79
    def pad_matrix(self, matrix: Matrix, pad_value: int=0) -> Matrix:
                               ^
SyntaxError: invalid syntax

Setup

  • OS: debian buster
  • Python version: 2.x
  • beets version: latest
  • Turning off plugins made problem go away (yes/no): no

Solution

The problem comes from the dependency munkres which dropped python 2 compatibility starting from version 1.1. So beets should limit the maximum version to<1.1 (1.0.12) in setup.py.

Leave a comment