Spotipy-configuration

If you are trying to set up Spotipy, like me, and you want to cache your credentials but are getting the following error,

warning:couldn't write token cache to /home/pi/spotipy_credentials

and have to auth on every run, it’s likely because in your call to

spotipy.Spotify(client_credentials_manager=SpotifyOAuth(...)

you specified cache_path as something like:

cache_path='/home/pi/spotipy_credentials/'

Because, naturally, that’s a path. In fact, cache_path is a full file path (i.e. it contains a writable filename). I did this instead:

cache_path='/home/pi/spotipy_credentials/.cache-' + username,

where username was a variable I wrote. As far as I know, you could just write make the filename ‘credentials.txt’ if you wanted…

Anyway, hope that helps someone else.