Funkwhale import in-place failed


I’m trying to import music to funkwhale.

  • I created a symlink between /mnt/mymusic and /var/www/funkwhale/import.
  • Then :
cd /var/www/funkwhale
source code/virtualenv/bin/activate
python code/api/ import_files <your library id> /var/funkwhale/import/mymusic --noinput --in-place --recursive

but I get this error :

2020-05-31 19:23:53,698 funkwhale_api.config INFO     Loaded env file at /var/www/funkwhale/code/config/.env
2020-05-31 19:23:53,699 funkwhale_api.config INFO     Running with no plugins
Checking imported paths against settings.MUSIC_DIRECTORY_PATH
For details, please refer to import reference 'cli-2020-05-31T17:23:54.967312+00:00' or URL https://fw.url/library/164dd45a-60b2-473b-8319-252d68d1a18b/upload?import=cli-2020-05-31T17%3A23%3A54.967312%2B00%3A00
Traceback (most recent call last):
  File "code/api/", line 27, in <module>
  File "/var/www/funkwhale/code/virtualenv/lib/python3.5/site-packages/django/core/management/", line 381, in execute_from_command_line
  File "/var/www/funkwhale/code/virtualenv/lib/python3.5/site-packages/django/core/management/", line 375, in execute
  File "/var/www/funkwhale/code/virtualenv/lib/python3.5/site-packages/django/core/management/", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/var/www/funkwhale/code/virtualenv/lib/python3.5/site-packages/django/core/management/", line 364, in execute
    output = self.handle(*args, **options)
  File "/var/www/funkwhale/code/api/funkwhale_api/music/management/commands/", line 217, in handle
    for i, entries in enumerate(batch(crawler, options["batch_size"])):
  File "/var/www/funkwhale/code/api/funkwhale_api/music/management/commands/", line 34, in batch
  File "/var/www/funkwhale/code/api/funkwhale_api/music/management/commands/", line 18, in crawl_dir
    with os.scandir(dir) as scanner:
AttributeError: __exit__

I remember this worked before last update (0.21)

I don’t know how to debug this :s

so the error was in the command python code/api/ import_files <your library id> /var/funkwhale/import/mymusic --noinput --in-place --recursive

you have to specify a file so this works :
python code/api/ import_files <your library id> /var/funkwhale/import/mymusic/* --noinput --in-place --recursive

I think I see what the issue is here. It’s going to need to be an upstream fix (I can see you’ve already opened an issue for it, so I’ll take a look at it this evening). I think it’s basically because the os.scandir() function is being used to check directories, but this doesn’t work with context in Python 3.5 (it was introduced in 3.6).


Release 0.21.1 has been pushed this morning, which includes a fix for this issue. I’m going to start looking at updating the package this evening, so you should see some movement on this soon.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.