object 'Spotify' has no attribute 'devices' - Spotipy 没有与轨道控制相关的所有属性

object 'Spotify' has no attribute 'devices' - Spotipy doesn't have all attributes related to track control

import sys
import spotipy
import spotipy.util as util

username = "un"
scope = 'user-library-read'

token = util.prompt_for_user_token(username,scope)

if token:
    sp = spotipy.Spotify(auth=token)
    devices=spotipy.client.Spotify.devices()
    print(devices)

else:
    print("Can't get token for", username)

这个小脚本应该打印出设备,但我收到错误 AttributeError: type object 'Spotify' has no attribute 'devices'

我检查过spotipy的版本。现在是2.4.4。安装已完成,但此 documentation 中的客户端对象的大部分播放功能都缺失,并给出相同的错误消息。他们为什么缺席?

  1. 我通过pip安装SpotiPy后遇到了同样的问题。
    我通过GitHub下载模块解决了我的问题,用pip uninstall spotipy卸载了错误的模块并安装了使用 python setup.py install.
  2. 下载模块
  3. 根据this page,正确的范围是user-read-playback-state
  4. 而不是使用 devices=spotipy.client.Spotify.devices(),您需要使用 devices=sp.devices()