[GH-ISSUE #30] Installation of spotapi does not install some required packages #18

Closed
opened 2026-02-27 19:06:27 +03:00 by kerem · 9 comments
Owner

Originally created by @svioletg on GitHub (May 5, 2025).
Original GitHub issue: https://github.com/Aran404/SpotAPI/issues/30

After running pip install spotapi and attempting to test with just import spotapi in the interpreter, I kept encountering a number of ModuleNotFoundErrors; they were for pymongo, redis, then websockets. I see in spotapi's setup.py these are specified as extras, but if they're supposed to be optional I would assume Just importing spotapi on its own shouldn't require them. Either that, or they should just be put in the regular requirements section. I would've just made a pull request for this but in case they are separate for a reason I decided to just open an issue for now.

Originally created by @svioletg on GitHub (May 5, 2025). Original GitHub issue: https://github.com/Aran404/SpotAPI/issues/30 After running `pip install spotapi` and attempting to test with just `import spotapi` in the interpreter, I kept encountering a number of `ModuleNotFoundError`s; they were for `pymongo`, `redis`, then `websockets`. I see in spotapi's [setup.py](https://github.com/Aran404/SpotAPI/blob/main/setup.py#L13) these are specified as extras, but if they're supposed to be optional I would assume Just importing spotapi on its own shouldn't require them. Either that, or they should just be put in the regular requirements section. I would've just made a pull request for this but in case they *are* separate for a reason I decided to just open an issue for now.
kerem closed this issue 2026-02-27 19:06:27 +03:00
Author
Owner

@Aran404 commented on GitHub (May 5, 2025):

I believe this is because you are importing the module from the init.py file which collects all the different classes into one file and this includes those modules aswell. Correct me if I'm wrong but if you directly imported the module instead of calling the init.py file, you won't need to install those packages. For example, from spotapi.playlist import ...

<!-- gh-comment-id:2851145192 --> @Aran404 commented on GitHub (May 5, 2025): I believe this is because you are importing the module from the __init__.py file which collects all the different classes into one file and this includes those modules aswell. Correct me if I'm wrong but if you directly imported the module instead of calling the __init__.py file, you won't need to install those packages. For example, from spotapi.playlist import ...
Author
Owner

@svioletg commented on GitHub (May 5, 2025):

It seems to still require them regardless of what modules are imported from it, e.g. these are from inside venv that I only ran pip install spotapi in:

>>> from spotapi.playlist import PublicPlaylist
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/__init__.py", line 1, in <module>
    from spotapi.artist import *
  File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/artist.py", line 7, in <module>
    from spotapi.client import BaseClient
  File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/client.py", line 12, in <module>
    from spotapi.utils.strings import parse_json_string
  File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/utils/__init__.py", line 2, in <module>
    from spotapi.utils.saver import *
  File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/utils/saver.py", line 12, in <module>
    import pymongo
ModuleNotFoundError: No module named 'pymongo'
>>> from spotapi.album import PublicAlbum
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/__init__.py", line 1, in <module>
    from spotapi.artist import *
  File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/artist.py", line 7, in <module>
    from spotapi.client import BaseClient
  File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/client.py", line 12, in <module>
    from spotapi.utils.strings import parse_json_string
  File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/utils/__init__.py", line 2, in <module>
    from spotapi.utils.saver import *
  File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/utils/saver.py", line 12, in <module>
    import pymongo
ModuleNotFoundError: No module named 'pymongo'
<!-- gh-comment-id:2852360423 --> @svioletg commented on GitHub (May 5, 2025): It seems to still require them regardless of what modules are imported from it, e.g. these are from inside venv that I only ran `pip install spotapi` in: ```python >>> from spotapi.playlist import PublicPlaylist Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/__init__.py", line 1, in <module> from spotapi.artist import * File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/artist.py", line 7, in <module> from spotapi.client import BaseClient File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/client.py", line 12, in <module> from spotapi.utils.strings import parse_json_string File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/utils/__init__.py", line 2, in <module> from spotapi.utils.saver import * File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/utils/saver.py", line 12, in <module> import pymongo ModuleNotFoundError: No module named 'pymongo' ``` ```python >>> from spotapi.album import PublicAlbum Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/__init__.py", line 1, in <module> from spotapi.artist import * File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/artist.py", line 7, in <module> from spotapi.client import BaseClient File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/client.py", line 12, in <module> from spotapi.utils.strings import parse_json_string File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/utils/__init__.py", line 2, in <module> from spotapi.utils.saver import * File "/home/violet/code/python/spotapi/.venv/lib/python3.13/site-packages/spotapi/utils/saver.py", line 12, in <module> import pymongo ModuleNotFoundError: No module named 'pymongo' ```
Author
Owner

@Aran404 commented on GitHub (May 6, 2025):

If I'm being honest I have no clue

<!-- gh-comment-id:2855550342 --> @Aran404 commented on GitHub (May 6, 2025): If I'm being honest I have no clue
Author
Owner

@Erriez commented on GitHub (May 7, 2025):

These packages are missing in requirements.txt after a clone of this repo and installing from requirements.txt:

pillow==10.4.0
pymongo==4.12.1
redis==6.0.0

Workaround: activate virtualenv, then install the packages manually:

pip install pandas pymongo redis
<!-- gh-comment-id:2859925795 --> @Erriez commented on GitHub (May 7, 2025): These packages are missing in [requirements.txt](https://github.com/Aran404/SpotAPI/blob/main/requirements.txt) after a clone of this repo and installing from `requirements.txt`: ``` pillow==10.4.0 pymongo==4.12.1 redis==6.0.0 ``` Workaround: activate virtualenv, then install the packages manually: ```sh pip install pandas pymongo redis ```
Author
Owner

@Aran404 commented on GitHub (May 7, 2025):

I think he wants a way to use the package without installing the "optional" requirements. I'm not very experienced with this stuff so I'm unsure as to how you get around this import issue.

<!-- gh-comment-id:2859942380 --> @Aran404 commented on GitHub (May 7, 2025): I think he wants a way to use the package without installing the "optional" requirements. I'm not very experienced with this stuff so I'm unsure as to how you get around this import issue.
Author
Owner

@svioletg commented on GitHub (May 7, 2025):

I don't personally mind having these packages installed, I more wanted to point out that in practice they seem required for any functionality of the SpotAPI, therefore having them not installed by default might create some confusion. I'm not deeply familiar with your dev workflow for this project so I wouldn't know where to start making suggestions for how to avoid needing them, but if you didn't want to do that and just make it so they are required I believe you could modify this section of your setup.py like so:

__install_require__ = [
    "requests",
    "colorama",
    "Pillow",
    "readerwriterlock",
    "tls_client",
    "typing_extensions",
    "validators",
]
__extras__ = {
    "websocket": ["websockets"],
    "redis": ["redis"],
    "pymongo": ["pymongo"],
}

...to...

__install_require__ = [
    "requests",
    "colorama",
    "Pillow",
    "pymongo",
    "readerwriterlock",
    "redis",
    "tls_client",
    "typing_extensions",
    "validators",
    "websockets"
]
<!-- gh-comment-id:2860046425 --> @svioletg commented on GitHub (May 7, 2025): I don't personally mind having these packages installed, I more wanted to point out that in practice they seem required for any functionality of the SpotAPI, therefore having them not installed by default might create some confusion. I'm not deeply familiar with your dev workflow for this project so I wouldn't know where to start making suggestions for how to avoid needing them, but if you didn't want to do that and just make it so they *are* required I believe you could modify this section of your `setup.py` like so: ```python __install_require__ = [ "requests", "colorama", "Pillow", "readerwriterlock", "tls_client", "typing_extensions", "validators", ] __extras__ = { "websocket": ["websockets"], "redis": ["redis"], "pymongo": ["pymongo"], } ``` ...to... ```python __install_require__ = [ "requests", "colorama", "Pillow", "pymongo", "readerwriterlock", "redis", "tls_client", "typing_extensions", "validators", "websockets" ] ```
Author
Owner

@Aran404 commented on GitHub (May 7, 2025):

Of course but I had some developers tell me to make them optional seeing that they aren't needed unless you use certain parts of SpotAPI (Savers) but I'll see if there's any work around.

<!-- gh-comment-id:2860187489 --> @Aran404 commented on GitHub (May 7, 2025): Of course but I had some developers tell me to make them optional seeing that they aren't needed unless you use certain parts of SpotAPI (Savers) but I'll see if there's any work around.
Author
Owner

@svioletg commented on GitHub (May 8, 2025):

I can see in spotapi's __init__.py there's these two lines: from spotapi.utils.saver import *, from spotapi.websocket import *. The same exists in utils/__init__.py, meaning no matter what you import, those modules with the optional dependencies are always imported. Personally, unless there's a reason for doing so that I'm unaware of, I would just recommend to remove all from x import * lines from both files, as from my testing the library seems to work just fine without them - aside from some slightly changed importing on the user side, e.g. from spotapi import Song would have to change to from spotapi.song import Song. If you'd like I can do some further testing with this change and make a pull request for it.

<!-- gh-comment-id:2864264539 --> @svioletg commented on GitHub (May 8, 2025): I can see in spotapi's [`__init__.py`](https://github.com/Aran404/SpotAPI/blob/main/spotapi/__init__.py) there's these two lines: `from spotapi.utils.saver import *`, `from spotapi.websocket import *`. The same exists in [`utils/__init__.py`](https://github.com/Aran404/SpotAPI/blob/main/spotapi/utils/__init__.py), meaning no matter what you import, those modules with the optional dependencies are *always* imported. Personally, unless there's a reason for doing so that I'm unaware of, I would just recommend to remove all `from x import *` lines from both files, as from my testing the library seems to work just fine without them - aside from some slightly changed importing on the user side, e.g. `from spotapi import Song` would have to change to `from spotapi.song import Song`. If you'd like I can do some further testing with this change and make a pull request for it.
Author
Owner

@Aran404 commented on GitHub (May 9, 2025):

My goal with that was that instead of importing the saver classes from the saver files, you could just import it straight from SpotAPI. I'll look into and see if that's a feasible solution. Thank you for help.

<!-- gh-comment-id:2867698029 --> @Aran404 commented on GitHub (May 9, 2025): My goal with that was that instead of importing the saver classes from the saver files, you could just import it straight from SpotAPI. I'll look into and see if that's a feasible solution. Thank you for help.
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SpotAPI#18
No description provided.