如何解决来自Spotipy的此客户端ID错误?

问题描述

我正在尝试使用python做一个Spotify项目,但出现此错误。 “没有client_id。传递它或设置spotipy_client_id环境变量。”

这是我的代码:

import spotipy
from spotipy.oauth2 import SpotifyClientCredentials

surfaces_url = 'https://open.spotify.com/artist/4ETSs924pXMzjIeD6E9b4u'

spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())

results = spotify.artist_albums(surfaces_url,album_type='album')
albums = results['items']

while results['next']:
    results = spotify.next(results)
    albums.extend(results['items'])

for album in albums:
    print(album['name'])

解决方法

尝试替换

    spotify = spotipy.Spotify(client_credentials_manager=SpotifyClientCredentials())

使用

    spotify = spotipy.Spotify(auth_manager = SpotifyOAuth(client_id = 'your client id here'))

看看是否有帮助

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...