[GH-ISSUE #865] ValueError on recommendations #533

Closed
opened 2026-02-27 23:23:11 +03:00 by kerem · 2 comments
Owner

Originally created by @Fertzzuu on GitHub (Oct 6, 2022).
Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/865

Describe the bug
A ValueError is thrown when calling recommendations with seed tracks:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Your code
recommendations = api.recommendations(seed_tracks=sample_tracks, limit=20)

Expected behavior
Return the recommendations

Output

File "/.../.venv/lib/python3.8/site-packages/spotipy/client.py", line 1631, in recommendations
    if seed_tracks:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Environment:

  • OS: Linux
  • Python version 3.8.10
  • spotipy version 2.20.0
Originally created by @Fertzzuu on GitHub (Oct 6, 2022). Original GitHub issue: https://github.com/spotipy-dev/spotipy/issues/865 **Describe the bug** A ValueError is thrown when calling recommendations with seed tracks: `ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()` **Your code** recommendations = api.recommendations(seed_tracks=sample_tracks, limit=20) **Expected behavior** Return the recommendations **Output** ``` File "/.../.venv/lib/python3.8/site-packages/spotipy/client.py", line 1631, in recommendations if seed_tracks: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all() ``` **Environment:** - OS: Linux - Python version 3.8.10 - spotipy version 2.20.0
kerem 2026-02-27 23:23:11 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@Peter-Schorn commented on GitHub (Oct 7, 2022):

Is sample_tracks a numpy array? If so, you need to convert it to a python list using list(sample_tracks) before you pass it into any methods in this library.

<!-- gh-comment-id:1271202173 --> @Peter-Schorn commented on GitHub (Oct 7, 2022): Is `sample_tracks` a numpy array? If so, you need to convert it to a python list using `list(sample_tracks)` before you pass it into any methods in this library.
Author
Owner

@dieser-niko commented on GitHub (May 23, 2024):

Closing as there is no activity or reply from the author.

<!-- gh-comment-id:2126608299 --> @dieser-niko commented on GitHub (May 23, 2024): Closing as there is no activity or reply from the author.
Sign in to join this conversation.
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/spotipy#533
No description provided.