tamland / python-tidal

Python API for TIDAL music streaming service
GNU Lesser General Public License v3.0
413 stars 110 forks source link

Circular import between tidalapi.media and tidalapi.session #156

Closed nawordar closed 1 year ago

nawordar commented 1 year ago

After updating to the git version of tidalapi and mopidy-tidal, I am getting the following error message:

lip 12 10:29:51 cezdro mopidy[1183304]: Traceback (most recent call last):
lip 12 10:29:51 cezdro mopidy[1183304]:   File "/home/cezdro/.local/pipx/venvs/mopidy/lib/python3.11/site-packages/mopidy/__main__.py", line 129, in main
lip 12 10:29:51 cezdro mopidy[1183304]:     extension.setup(registry)
lip 12 10:29:51 cezdro mopidy[1183304]:   File "/home/cezdro/.local/pipx/venvs/mopidy/lib/python3.11/site-packages/mopidy_tidal/__init__.py", line 37, in setup
lip 12 10:29:51 cezdro mopidy[1183304]:     from .backend import TidalBackend
lip 12 10:29:51 cezdro mopidy[1183304]:   File "/home/cezdro/.local/pipx/venvs/mopidy/lib/python3.11/site-packages/mopidy_tidal/backend.py", line 9, in <module>
lip 12 10:29:51 cezdro mopidy[1183304]:     from tidalapi import Config, Quality, Session
lip 12 10:29:51 cezdro mopidy[1183304]:   File "/home/cezdro/.local/pipx/venvs/mopidy/lib/python3.11/site-packages/tidalapi/__init__.py", line 4, in <module>
lip 12 10:29:51 cezdro mopidy[1183304]:     from .media import Track, Video  # noqa: F401
lip 12 10:29:51 cezdro mopidy[1183304]:     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
lip 12 10:29:51 cezdro mopidy[1183304]:   File "/home/cezdro/.local/pipx/venvs/mopidy/lib/python3.11/site-packages/tidalapi/media.py", line 34, in <module>
lip 12 10:29:51 cezdro mopidy[1183304]:     class Media:
lip 12 10:29:51 cezdro mopidy[1183304]:   File "/home/cezdro/.local/pipx/venvs/mopidy/lib/python3.11/site-packages/tidalapi/media.py", line 63, in Media
lip 12 10:29:51 cezdro mopidy[1183304]:     self, session: tidalapi.session.Session, media_id: Optional[str] = None
lip 12 10:29:51 cezdro mopidy[1183304]:                    ^^^^^^^^^^^^^^^^
lip 12 10:29:51 cezdro mopidy[1183304]: AttributeError: partially initialized module 'tidalapi' has no attribute 'session' (most likely due to a circular import)

It is caused a recent change introduced in 019ce3d. After running these commands, Mopidy-Tidal runs fine:

pipx uninject mopidy tidalapi
pipx inject mopidy git+https://github.com/tamland/python-tidal.git@052e27a50d90cc51535303caf1f97db675361528

I originally posted this as a comment in #57, but this is a different issue.

tehkillerbee commented 1 year ago

Thanks, I have also added it to mopidy-tidal since the fix will most likely be needed there.

tehkillerbee commented 1 year ago

@nawordar Can you check if this is still an issue? I cannot replicate the bug after installing the latest tidalapi and mopidy-tidal from git.

nawordar commented 1 year ago

No, it is not an issue anymore, although I had to install latest tidalapi after mopidy-tidal. Otherwise, tidalapi is being overwritten with an older version.

tehkillerbee commented 1 year ago

Great. Yes, it will be necessary to install tidalapi manually until we update the PyPi release.

Closing.