Holzhaus / beets-extrafiles

A plugin for beets that copies additional files and directories during the import process.
MIT License
46 stars 10 forks source link

Installing extrafiles causes other beets plugins to fail #27

Open ItchyData opened 3 years ago

ItchyData commented 3 years ago

I installed the extrafiles plugin to my beets installation: pip3 install --user beets-extrafiles

Then when I do an import all my other plugins fail to load. This happens when extrafiles is enabled in the config or not. The only fix that I've found is to uninstall the plugin. Any suggestions?

** error loading plugin bucket:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/beets/plugins.py", line 275, in load_plugins
    namespace = __import__(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.bucket'

** error loading plugin convert:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/beets/plugins.py", line 275, in load_plugins
    namespace = __import__(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.convert'

** error loading plugin edit:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/beets/plugins.py", line 275, in load_plugins
    namespace = __import__(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.edit'

/usr/local/lib/python3.9/site-packages/beets/mediafile.py:21: UserWarning: beets.mediafile is deprecated; use mediafile instead
  warnings.warn("beets.mediafile is deprecated; use mediafile instead")
** error loading plugin inline:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/beets/plugins.py", line 275, in load_plugins
    namespace = __import__(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.inline'

** error loading plugin lastgenre:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/beets/plugins.py", line 275, in load_plugins
    namespace = __import__(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.lastgenre'

** error loading plugin mbsubmit:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/beets/plugins.py", line 275, in load_plugins
    namespace = __import__(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.mbsubmit'

** error loading plugin mbsync:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/beets/plugins.py", line 275, in load_plugins
    namespace = __import__(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.mbsync'

** error loading plugin missing:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/beets/plugins.py", line 275, in load_plugins
    namespace = __import__(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.missing'

** error loading plugin rewrite:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/beets/plugins.py", line 275, in load_plugins
    namespace = __import__(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.rewrite'

** error loading plugin the:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/beets/plugins.py", line 275, in load_plugins
    namespace = __import__(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.the'
Goorzhel commented 3 years ago

The issue might not be with the plugin itself, but with beets' handling of the existence of multiple plugin folders.

Background

I'm on Void Linux, with beets installed as a system package.

❯ xrs beets
[*] beets-1.4.9_4 Media library management system for obsessive-compulsive music geeks
❯ xbps-query -f beets | grep beetsplug | head -5
/usr/lib/python3.9/site-packages/beetsplug/__init__.py
/usr/lib/python3.9/site-packages/beetsplug/absubmit.py
/usr/lib/python3.9/site-packages/beetsplug/acousticbrainz.py
/usr/lib/python3.9/site-packages/beetsplug/badfiles.py
/usr/lib/python3.9/site-packages/beetsplug/beatport.py

Problem (ver. 1)

When I first pip-installed beets-extrafiles, I ran into the problem in beetbox/beets#3717:

❯ pip install beets-extrafiles
Defaulting to user installation because normal site-packages is not writeable
<...>
Successfully installed beets-extrafiles-0.0.7
❯ beet version
Traceback (most recent call last):
  File "/usr/bin/beet", line 33, in <module>
    sys.exit(load_entry_point('beets==1.4.9', 'console_scripts', 'beet')())
  File "/usr/lib/python3.9/site-packages/beets/ui/__init__.py", line 1266, in main
    _raw_main(args)
  File "/usr/lib/python3.9/site-packages/beets/ui/__init__.py", line 1249, in _raw_main
    subcommands, plugins, lib = _setup(options, lib)
  File "/usr/lib/python3.9/site-packages/beets/ui/__init__.py", line 1135, in _setup
    plugins = _load_plugins(config)
  File "/usr/lib/python3.9/site-packages/beets/ui/__init__.py", line 1114, in _load_plugins
    beetsplug.__path__ = paths + beetsplug.__path__
TypeError: can only concatenate list (not "_NamespacePath") to list

A comment in that thread clued me into a missing __init__, so I thought to solve it via brute force, and that led me to the problem OP faces:

Problem (ver. 2)

❯ cp /usr/lib/python3.9/site-packages/beetsplug/__init__.py ~/.local/lib/python3.9/site-packages/beetsplug
'/usr/lib/python3.9/site-packages/beetsplug/__init__.py' -> '/home/ag/.local/lib/python3.9/site-packages/beetsplug/__init__.py'
❯ beet version
** error loading plugin the:
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/beets/plugins.py", line 273, in load_plugins
    namespace = __import__(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.the'
** error loading plugin ftintitle:
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/beets/plugins.py", line 273, in load_plugins
    namespace = __import__(modname, None, None)
ModuleNotFoundError: No module named 'beetsplug.ftintitle'
<...>
ModuleNotFoundError: No module named 'beetsplug.zero'
beets version 1.4.9
Python version 3.9.2
plugins: extrafiles

pdb confirms that beet now thinks beetplug lives in my .local/lib, away from all the built-in plugins:

❯ python -m pdb $(which beet)
> /usr/bin/beet(3)<module>()
-> import re
(Pdb) b /usr/lib/python3.9/site-packages/beets/ui/__init__.py:1122
Breakpoint 1 at /usr/lib/python3.9/site-packages/beets/ui/__init__.py:1122
(Pdb) c
** error loading plugin the:
<...>
-> return plugins
(Pdb) beetsplug.__path__
['/home/ag/.local/lib/python3.9/site-packages/beetsplug']

Solution (hackish)

As much as I try to leave 100% of package management to the distro, using pip as root fixed the immediate issue for me.

❯ sudo pip install beets-extrafiles
<...>
Installing collected packages: beets-extrafiles
Successfully installed beets-extrafiles-0.0.7
ag@losangeles ~ ❯ beet version
beets version 1.4.9
Python version 3.9.2
plugins: duplicates, edit, extrafiles, ftintitle, the, zero
ItchyData commented 3 years ago

sudo pip install beets-extrafiles

This worked for me. Thanks. I agree that using sudo is not ideal, so I'll leave this bug open for now, but I appreciate the workaround.

JOJ0 commented 1 year ago

Hi, I'm facing the same error. Worked around it by deleting my whole beets venv. Fortunately I had written an install script taking care of all the beets plugin installation and all dependencies.

Wanted to add: Installing this plugin in a virtual python environment (created using pyenv) breaks the whole beets installation. No other plugins can be found anymore and I did not find a way to fix it except of deleting my whole venv and start from scratch.

@Holzhaus this is a pretty bad situation currently and could break other peoples beets installations as well. What do you think about adding this current bug and the workaround of installing as sudo to your documentation. It looks like you have other things to do currently than keep maintaining this beets plugin, which certainly is perfectly find and how life goes. But shouldn't we warn people at least? If you agree I will try to find half an hour and send a docs-changing-PR. HTH!

env-media commented 1 year ago

Worthwhile endeavor @JOJ0. Fork this repo and add the documentation to your fork so at least it will be searchable/ can be linked from this issue. Stumbled upon this as I am experiencing a related issue after reconfiguring a new box with my old box's beet environment.

JOJ0 commented 1 year ago

@env-media I'm not sure if I'm motivated anymore since I've got many other "beetsy" things going on. By any chance you wanna play the role of the hero here? :-))