Martin Zegarelli
Martin Zegarelli

Reputation: 73

AttributeError: 'Spotify' object has no attribute 'current_user_saved_tracks'

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'

Upvotes: 2

Views: 3692

Answers (2)

Nicolai Weitkemper
Nicolai Weitkemper

Reputation: 634

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)

Upvotes: 2

Mangohero1
Mangohero1

Reputation: 1912

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.

Upvotes: 5

Related Questions