2

Using Spotipy and am attempting to 'current_user_recently_played'

token = util.prompt_for_user_token(username, scope = scope, client_id=client_id, client_secret=client_secret, redirect_uri=redirect_uri)

sp = spotipy.Spotify(auth = token)

saved = sp.current_user_saved_tracks()
print(saved)
recent = sp.current_user_recently_played()
print(recent)

sp.current_user_saved_tracks() runs just fine, sp.current_user_recently_played() apparently doesn't exist even though it is clearly in the documentation https://spotipy.readthedocs.io/en/latest/#more-examples.

Running - v2.4.4 - January 4, 2017

Thanks ahead of time.

Traceback (most recent call last):
  File "C:\Users\Martin\Google Drive\Python\Spotify\try_req.py", line 19, in <module>
recent = sp.current_user_recently_played()
AttributeError: 'Spotify' object has no attribute 'current_user_recently_played'

2 Answers2

5

You're going to have to get the code manually. The installation via pip is outdated.

Navigate to where you installed Spotipy (for me it was C:\Users\[myName]\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\spotipy), open client.py and replace the code with the newer code found here.

Mangohero1
  • 1,832
  • 2
  • 12
  • 20
  • 4
    you can use `pip show spotipy` and reference the "Location" path to find where the package is installed – s2t2 Jun 30 '18 at 18:20
  • this answer should be marked as correct. this fixed it for me, finally. thanks! – slow Jun 17 '19 at 09:53
2

This is due to the outdated version on PyPi, as Mangohero1 already pointed out. The following method is probably easier than manually changing code.

You can install the latest code like this:

pip install git+https://github.com/plamere/spotipy.git --upgrade

(source)

Nicolai Weitkemper
  • 403
  • 1
  • 9
  • 18