bbye98 / minim

A collection of music service (iTunes, Qobuz, Spotify, TIDAL) APIs for media information retrieval and semi-automated music tagging.
https://bbye98.github.io/minim/
GNU General Public License v3.0
41 stars 3 forks source link

ImportError: cannot import name 'FFMPEG_CODECS' from partially initialized module 'minim' (most likely due to a circular import) #10

Closed s-lopez closed 6 months ago

s-lopez commented 6 months ago

Hello!

I was about to give minim a try, since it looks super interesting, and I'm getting this circular import error as soon as I try to import minim: ImportError: cannot import name 'FFMPEG_CODECS' from partially initialized module 'minim' (most likely due to a circular import)

I followed the instructions to install the dependencies and the project in editable mode with virtualenv. I'm using Python 3.11 and macOS 14.3.1.

The error appears as soon as I import minim (python -c "import minim").

I've looked into it and indeed, src/minim/__init__.py contains from . import audio, itunes, qobuz, spotify, tidal, utility # noqa: E402 in line 42, and src/minim/audio.py has the following in line 22: from . import utility, FOUND_FFMPEG, FFMPEG_CODECS. FOUND_FFMPEG is defined in __init__.py.

bbye98 commented 6 months ago

Hi! Thanks for opening an issue.

I was unable to reproduce this issue by cloning the GitHub repository as it is now and installing it in a new Conda environment. Can you give me the exact steps you used to initialize your virtualenv?

Or better question: do you have FFmpeg installed? If not, I think it might be because I included FFMPEG_CODECS in __all__ in __init__.py, even if it was never defined if you don't have FFmpeg. It may also be possible that shutil is not able to find your installation of FFmpeg: https://github.com/pyinstaller/pyinstaller/issues/5925.

I'm going to try my best to figure out the root cause, but I only have access to Windows and Ubuntu currently, not macOS. Hopefully this is an OS-independent issue!

Thanks!

s-lopez commented 6 months ago

Thanks to you for taking a look at this so quickly and for publishing your library!

Ok, good news: Installing FFmpeg with homebrew and installing the full dependencies from requirements.txt does the trick. I can now successfully import the package. Thanks!

Now the details:

So I'm guessing the issue is indeed OS-independent, except for the conda part, of course 😄

bbye98 commented 6 months ago

Thanks for the detailed response! I will address the cryptography issue when I get home and push a fix to GitHub.

s-lopez commented 6 months ago

@bbye98 I think other users might still see the circular import error if they don't have FFmpeg in their system.

bbye98 commented 6 months ago

Whoops! Forgot to update audio.py. Hopefully this push fixes the issue.